[PATCH] D82294: [SVE] Fix scalable vector bug in DataLayout::getIntPtrType
David Sherwood via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 22 06:25:12 PDT 2020
david-arm created this revision.
Herald added subscribers: llvm-commits, psnobl, rkruppe, hiraditya, tschuett.
Herald added a reviewer: efriedma.
Herald added a project: LLVM.
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
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D82294
Files:
llvm/lib/IR/DataLayout.cpp
llvm/test/Transforms/InstCombine/vector_gep1.ll
Index: llvm/test/Transforms/InstCombine/vector_gep1.ll
===================================================================
--- llvm/test/Transforms/InstCombine/vector_gep1.ll
+++ llvm/test/Transforms/InstCombine/vector_gep1.ll
@@ -62,3 +62,13 @@
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
+}
Index: llvm/lib/IR/DataLayout.cpp
===================================================================
--- llvm/lib/IR/DataLayout.cpp
+++ llvm/lib/IR/DataLayout.cpp
@@ -791,8 +791,10 @@
"Expected a pointer or pointer vector type.");
unsigned NumBits = getPointerTypeSizeInBits(Ty);
IntegerType *IntTy = IntegerType::get(Ty->getContext(), NumBits);
- if (VectorType *VecTy = dyn_cast<VectorType>(Ty))
+ if (auto *VecTy = dyn_cast<FixedVectorType>(Ty))
return FixedVectorType::get(IntTy, VecTy->getNumElements());
+ else if (auto *VecTy = dyn_cast<ScalableVectorType>(Ty))
+ return ScalableVectorType::get(IntTy, VecTy->getMinNumElements());
return IntTy;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82294.272402.patch
Type: text/x-patch
Size: 1649 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200622/afb27b77/attachment-0001.bin>
More information about the llvm-commits
mailing list