[SVE] Fix scalable vector bug in DataLayout::getIntPtrType
authorDavid Sherwood <david.sherwood@arm.com>
Mon, 22 Jun 2020 13:09:34 +0000 (14:09 +0100)
committerDavid Sherwood <david.sherwood@arm.com>
Fri, 26 Jun 2020 06:58:45 +0000 (07:58 +0100)
Fixed an issue in DataLayout::getIntPtrType where we were assuming
the input type was always a fixed vector type, which isn't true.

Added a test that exposed the problem to:

  Transforms/InstCombine/vector_gep1.ll

Differential Revision: https://reviews.llvm.org/D82294

llvm/lib/IR/DataLayout.cpp
llvm/test/Transforms/InstCombine/vector_gep1.ll

index ca8f66d..58ef87a 100644 (file)
@@ -792,7 +792,7 @@ Type *DataLayout::getIntPtrType(Type *Ty) const {
   unsigned NumBits = getPointerTypeSizeInBits(Ty);
   IntegerType *IntTy = IntegerType::get(Ty->getContext(), NumBits);
   if (VectorType *VecTy = dyn_cast<VectorType>(Ty))
-    return FixedVectorType::get(IntTy, VecTy->getNumElements());
+    return VectorType::get(IntTy, VecTy);
   return IntTy;
 }
 
index 8e5bcf9..4eb449e 100644 (file)
@@ -62,3 +62,13 @@ define <2 x i32*> @test7(<2 x {i32, i32}*> %a) {
   ret <2 x i32*> %w
 }
 
+define <vscale x 2 x i1> @test8() {
+; CHECK-LABEL: @test8(
+; CHECK-NEXT:    ret <vscale x 2 x i1> icmp ult (<vscale x 2 x i64> zext (<vscale x 2 x i32> shufflevector (<vscale x 2 x i32> insertelement (<vscale x 2 x i32> undef, i32 1, i32 0), <vscale x 2 x i32> undef, <vscale x 2 x i32> zeroinitializer) to <vscale x 2 x i64>), <vscale x 2 x i64> zeroinitializer)
+;
+  %ins = insertelement <vscale x 2 x i32> undef, i32 1, i32 0
+  %b = shufflevector <vscale x 2 x i32> %ins, <vscale x 2 x i32> undef, <vscale x 2 x i32> zeroinitializer
+  %c = inttoptr <vscale x 2 x i32> %b to <vscale x 2 x i8*>
+  %d = icmp ult <vscale x 2 x i8*> %c, zeroinitializer
+  ret <vscale x 2 x i1> %d
+}