Skip to content

Commit f0520b5

Browse files
committed
fix vector LEA typing judgment
1 parent 340db05 commit f0520b5

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/thorin/primop.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,17 @@ Vector::Vector(World& world, Defs args, Debug dbg)
5959
LEA::LEA(World& world, const Def* ptr, const Def* index, Debug dbg)
6060
: Def(world, Node_LEA, nullptr, {ptr, index}, dbg)
6161
{
62-
auto [type, len] = deconstruct_vector_type(ptr->type());
63-
auto ptr_type = type->as<PtrType>();
62+
auto [ptr_type, len] = deconstruct_vector_type<PtrType>(ptr->type());
63+
auto type = ptr_type->pointee();
6464

65-
if (auto tuple = ptr_pointee()->isa<TupleType>()) {
65+
if (auto tuple = type->isa<TupleType>()) {
6666
set_type(world.vector_or_scalar_type(world.ptr_type(get(tuple->types(), index), ptr_type->addr_space()), len));
67-
} else if (auto array = ptr_pointee()->isa<ArrayType>()) {
67+
} else if (auto array = type->isa<ArrayType>()) {
6868
set_type(world.vector_or_scalar_type(world.ptr_type(array->elem_type(), ptr_type->addr_space()), len));
69-
} else if (auto struct_type = ptr_pointee()->isa<StructType>()) {
69+
} else if (auto struct_type = type->isa<StructType>()) {
7070
set_type(world.vector_or_scalar_type(world.ptr_type(get(struct_type->types(), index), ptr_type->addr_space()), len));
71-
} else if (auto vector_type = ptr_pointee()->isa<VectorType>()) {
72-
set_type(world.vector_or_scalar_type(world.ptr_type(vector_type->scalarize(), ptr_type->addr_space()), len));
71+
} else if (len > 1) {
72+
set_type(world.vector_or_scalar_type(world.ptr_type(type, ptr_type->addr_space()), len));
7373
} else {
7474
THORIN_UNREACHABLE;
7575
}
@@ -79,7 +79,7 @@ const Type* LEA::ptr_pointee() const {
7979
auto [base, len] = deconstruct_vector_type<PtrType>(ptr()->type());
8080
if (len > 1)
8181
return world().vector_type(base->pointee()->as<ScalarType>(), len);
82-
return base;
82+
return base->pointee();
8383
}
8484

8585
Known::Known(World& world, const Def* def, Debug dbg)

0 commit comments

Comments
 (0)