Skip to content

Commit e0acdf3

Browse files
committed
Don't create new splats, use isSplatValue
1 parent 0b09326 commit e0acdf3

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,9 +1478,8 @@ Value *InstCombinerImpl::foldReversedIntrinsicOperands(IntrinsicInst *II) {
14781478
NewArgs.push_back(Arg);
14791479
else if (match(&Arg, m_VecReverse(m_Value(X))))
14801480
NewArgs.push_back(X);
1481-
else if (Value *Splat = getSplatValue(Arg))
1482-
NewArgs.push_back(Builder.CreateVectorSplat(
1483-
cast<VectorType>(Arg->getType())->getElementCount(), Splat));
1481+
else if (isSplatValue(Arg))
1482+
NewArgs.push_back(Arg);
14841483
else if (match(&Arg, m_ImmConstant(C)))
14851484
NewArgs.push_back(Builder.CreateVectorReverse(C));
14861485
else

llvm/test/Transforms/InstCombine/vector-reverse.ll

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,20 @@ define <vscale x 4 x float> @reverse_binop_reverse_intrinsic_splat_LHS(<vscale x
758758
ret <vscale x 4 x float> %maxnum.rev
759759
}
760760

761+
; Negative test: Make sure that splats with poison aren't considered splats
762+
define <4 x float> @reverse_binop_reverse_intrinsic_splat_with_poison(<4 x float> %a) {
763+
; CHECK-LABEL: @reverse_binop_reverse_intrinsic_splat_with_poison(
764+
; CHECK-NEXT: [[TMP1:%.*]] = call <4 x float> @llvm.maxnum.v4f32(<4 x float> [[A:%.*]], <4 x float> <float 1.000000e+00, float poison, float 1.000000e+00, float 1.000000e+00>)
765+
; CHECK-NEXT: [[MAXNUM:%.*]] = shufflevector <4 x float> [[TMP1]], <4 x float> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
766+
; CHECK-NEXT: [[MAXNUM_REV:%.*]] = tail call <4 x float> @llvm.vector.reverse.v4f32(<4 x float> [[MAXNUM]])
767+
; CHECK-NEXT: ret <4 x float> [[MAXNUM_REV]]
768+
;
769+
%a.rev = tail call <4 x float> @llvm.vector.reverse(<4 x float> %a)
770+
%maxnum = call <4 x float> @llvm.maxnum.v4f32(<4 x float> <float 1.0, float 1.0, float poison, float 1.0>, <4 x float> %a.rev)
771+
%maxnum.rev = tail call <4 x float> @llvm.vector.reverse(<4 x float> %maxnum)
772+
ret <4 x float> %maxnum.rev
773+
}
774+
761775
define <4 x float> @reverse_binop_reverse_intrinsic_constant_RHS(<4 x float> %a) {
762776
; CHECK-LABEL: @reverse_binop_reverse_intrinsic_constant_RHS(
763777
; CHECK-NEXT: [[TMP1:%.*]] = call <4 x float> @llvm.maxnum.v4f32(<4 x float> [[A:%.*]], <4 x float> <float 3.000000e+00, float 2.000000e+00, float 1.000000e+00, float 0.000000e+00>)

0 commit comments

Comments
 (0)