[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.
This commit is contained in:
Sanjay Patel 2020-06-20 15:18:27 -04:00
parent 90c1af106a
commit 741e20f3d6
2 changed files with 14 additions and 2 deletions

View File

@ -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;

View File

@ -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
}