[llvm] 741e20f - [VectorCombine] fix assert for type of compare operand

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 20 12:24:51 PDT 2020


Author: Sanjay Patel
Date: 2020-06-20T15:20:17-04:00
New Revision: 741e20f3d61964f2d3b1b32971083566be00bab6

URL: https://github.com/llvm/llvm-project/commit/741e20f3d61964f2d3b1b32971083566be00bab6
DIFF: https://github.com/llvm/llvm-project/commit/741e20f3d61964f2d3b1b32971083566be00bab6.diff

LOG: [VectorCombine] fix assert for type of compare operand

As shown in the post-commit comment for D81661 - we need to
loosen the type assertion to allow scalarization of a compare
for vectors of pointers.

Added: 
    

Modified: 
    llvm/lib/Transforms/Vectorize/VectorCombine.cpp
    llvm/test/Transforms/VectorCombine/X86/scalarize-cmp.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index a133d5433a57..1474ed0d5c69 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -395,8 +395,9 @@ static bool scalarizeBinopOrCmp(Instruction &I,
   Type *VecTy = I.getType();
   assert(VecTy->isVectorTy() &&
          (IsConst0 || IsConst1 || V0->getType() == V1->getType()) &&
-         (ScalarTy->isIntegerTy() || ScalarTy->isFloatingPointTy()) &&
-         "Unexpected types for insert into binop");
+         (ScalarTy->isIntegerTy() || ScalarTy->isFloatingPointTy() ||
+          ScalarTy->isPointerTy()) &&
+         "Unexpected types for insert element into binop or cmp");
 
   unsigned Opcode = I.getOpcode();
   int ScalarOpCost, VectorOpCost;

diff  --git a/llvm/test/Transforms/VectorCombine/X86/scalarize-cmp.ll b/llvm/test/Transforms/VectorCombine/X86/scalarize-cmp.ll
index fe2d1f0a5597..4774f64d08b5 100644
--- a/llvm/test/Transforms/VectorCombine/X86/scalarize-cmp.ll
+++ b/llvm/test/Transforms/VectorCombine/X86/scalarize-cmp.ll
@@ -277,3 +277,14 @@ define <4 x float> @vec_select_use2(<4 x float> %x, <4 x float> %y, float %a) {
   %r = select <4 x i1> %cond, <4 x float> %x, <4 x float> %y
   ret <4 x float> %r
 }
+
+define <4 x i1> @vector_of_pointers(i32* %t1) {
+; CHECK-LABEL: @vector_of_pointers(
+; CHECK-NEXT:    [[T6_SCALAR:%.*]] = icmp ne i32* [[T1:%.*]], null
+; CHECK-NEXT:    [[T6:%.*]] = insertelement <4 x i1> undef, i1 [[T6_SCALAR]], i64 0
+; CHECK-NEXT:    ret <4 x i1> [[T6]]
+;
+  %t5 = insertelement <4 x i32*> undef, i32* %t1, i32 0
+  %t6 = icmp ne <4 x i32*> %t5, zeroinitializer
+  ret <4 x i1> %t6
+}


        


More information about the llvm-commits mailing list