Skip to content

Commit 8718719

Browse files
committed
[InstCombine] Fold shuffled intrinsic operands with constants
1 parent 24e82ca commit 8718719

File tree

6 files changed

+63
-55
lines changed

6 files changed

+63
-55
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,9 +1399,8 @@ static Instruction *factorizeMinMaxTree(IntrinsicInst *II) {
13991399

14001400
/// If all arguments of the intrinsic are unary shuffles with the same mask,
14011401
/// try to shuffle after the intrinsic.
1402-
static Instruction *
1403-
foldShuffledIntrinsicOperands(IntrinsicInst *II,
1404-
InstCombiner::BuilderTy &Builder) {
1402+
Instruction *
1403+
InstCombinerImpl::foldShuffledIntrinsicOperands(IntrinsicInst *II) {
14051404
// TODO: This should be extended to handle other intrinsics like fshl, ctpop,
14061405
// etc. Use llvm::isTriviallyVectorizable() and related to determine
14071406
// which intrinsics are safe to shuffle?
@@ -1419,9 +1418,11 @@ foldShuffledIntrinsicOperands(IntrinsicInst *II,
14191418
}
14201419

14211420
Value *X;
1421+
Constant *C;
14221422
ArrayRef<int> Mask;
1423-
if (!match(II->getArgOperand(0),
1424-
m_Shuffle(m_Value(X), m_Undef(), m_Mask(Mask))))
1423+
auto *NonConstArg = find_if_not(II->args(), IsaPred<Constant>);
1424+
if (!NonConstArg ||
1425+
!match(NonConstArg, m_Shuffle(m_Value(X), m_Undef(), m_Mask(Mask))))
14251426
return nullptr;
14261427

14271428
// At least 1 operand must have 1 use because we are creating 2 instructions.
@@ -1433,11 +1434,19 @@ foldShuffledIntrinsicOperands(IntrinsicInst *II,
14331434
NewArgs[0] = X;
14341435
Type *SrcTy = X->getType();
14351436
for (unsigned i = 1, e = II->arg_size(); i != e; ++i) {
1436-
if (!match(II->getArgOperand(i),
1437-
m_Shuffle(m_Value(X), m_Undef(), m_SpecificMask(Mask))) ||
1438-
X->getType() != SrcTy)
1437+
if (match(II->getArgOperand(i),
1438+
m_Shuffle(m_Value(X), m_Undef(), m_SpecificMask(Mask))) &&
1439+
X->getType() == SrcTy)
1440+
NewArgs[i] = X;
1441+
else if (match(II->getArgOperand(i), m_ImmConstant(C))) {
1442+
// If it's a constant, try find the constant that would be shuffled to C.
1443+
if (Constant *ShuffledC =
1444+
unshuffleConstant(Mask, C, cast<VectorType>(SrcTy)))
1445+
NewArgs[i] = ShuffledC;
1446+
else
1447+
return nullptr;
1448+
} else
14391449
return nullptr;
1440-
NewArgs[i] = X;
14411450
}
14421451

14431452
// intrinsic (shuf X, M), (shuf Y, M), ... --> shuf (intrinsic X, Y, ...), M
@@ -3849,7 +3858,7 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
38493858
if (Instruction *R = FoldOpIntoSelect(*II, Sel))
38503859
return R;
38513860

3852-
if (Instruction *Shuf = foldShuffledIntrinsicOperands(II, Builder))
3861+
if (Instruction *Shuf = foldShuffledIntrinsicOperands(II))
38533862
return Shuf;
38543863

38553864
// Some intrinsics (like experimental_gc_statepoint) can be used in invoke

llvm/lib/Transforms/InstCombine/InstCombineInternal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final
147147
Instruction *visitAddrSpaceCast(AddrSpaceCastInst &CI);
148148
Instruction *foldItoFPtoI(CastInst &FI);
149149
Instruction *visitSelectInst(SelectInst &SI);
150+
Instruction *foldShuffledIntrinsicOperands(IntrinsicInst *II);
150151
Instruction *visitCallInst(CallInst &CI);
151152
Instruction *visitInvokeInst(InvokeInst &II);
152153
Instruction *visitCallBrInst(CallBrInst &CBI);
@@ -604,6 +605,8 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final
604605
Instruction *foldVectorBinop(BinaryOperator &Inst);
605606
Instruction *foldVectorSelect(SelectInst &Sel);
606607
Instruction *foldSelectShuffle(ShuffleVectorInst &Shuf);
608+
Constant *unshuffleConstant(ArrayRef<int> ShMask, Constant *C,
609+
VectorType *NewCTy);
607610

608611
/// Given a binary operator, cast instruction, or select which has a PHI node
609612
/// as operand #0, see if we can fold the instruction into the PHI (which is

llvm/lib/Transforms/InstCombine/InstructionCombining.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2100,8 +2100,8 @@ static bool shouldMergeGEPs(GEPOperator &GEP, GEPOperator &Src) {
21002100
//
21012101
// A 1-to-1 mapping is not required. Example:
21022102
// ShMask = <1,1,2,2> and C = <5,5,6,6> --> NewC = <poison,5,6,poison>
2103-
static Constant *unshuffleConstant(ArrayRef<int> ShMask, Constant *C,
2104-
VectorType *NewCTy) {
2103+
Constant *InstCombinerImpl::unshuffleConstant(ArrayRef<int> ShMask, Constant *C,
2104+
VectorType *NewCTy) {
21052105
if (isa<ScalableVectorType>(NewCTy)) {
21062106
Constant *Splat = C->getSplatValue();
21072107
if (!Splat)

llvm/test/Transforms/InstCombine/fma.ll

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -804,10 +804,9 @@ define <2 x float> @fma_unary_shuffle_ops_narrowing(<3 x float> %x, <3 x float>
804804

805805
define <2 x float> @fma_unary_shuffle_ops_1_const(<2 x float> %x, <2 x float> %y) {
806806
; CHECK-LABEL: @fma_unary_shuffle_ops_1_const(
807-
; CHECK-NEXT: [[A:%.*]] = shufflevector <2 x float> [[X:%.*]], <2 x float> poison, <2 x i32> <i32 1, i32 0>
808-
; CHECK-NEXT: [[B:%.*]] = shufflevector <2 x float> [[Y:%.*]], <2 x float> poison, <2 x i32> <i32 1, i32 0>
809-
; CHECK-NEXT: [[R:%.*]] = call <2 x float> @llvm.fma.v2f32(<2 x float> [[A]], <2 x float> <float 1.000000e+00, float 2.000000e+00>, <2 x float> [[B]])
810-
; CHECK-NEXT: ret <2 x float> [[R]]
807+
; CHECK-NEXT: [[Y:%.*]] = call <2 x float> @llvm.fma.v2f32(<2 x float> [[X:%.*]], <2 x float> <float 2.000000e+00, float 1.000000e+00>, <2 x float> [[Y1:%.*]])
808+
; CHECK-NEXT: [[B:%.*]] = shufflevector <2 x float> [[Y]], <2 x float> poison, <2 x i32> <i32 1, i32 0>
809+
; CHECK-NEXT: ret <2 x float> [[B]]
811810
;
812811
%a = shufflevector <2 x float> %x, <2 x float> poison, <2 x i32> <i32 1, i32 0>
813812
%b = shufflevector <2 x float> %y, <2 x float> poison, <2 x i32> <i32 1, i32 0>
@@ -817,9 +816,9 @@ define <2 x float> @fma_unary_shuffle_ops_1_const(<2 x float> %x, <2 x float> %y
817816

818817
define <2 x float> @fma_unary_shuffle_ops_2_const(<2 x float> %x) {
819818
; CHECK-LABEL: @fma_unary_shuffle_ops_2_const(
820-
; CHECK-NEXT: [[A:%.*]] = shufflevector <2 x float> [[X:%.*]], <2 x float> poison, <2 x i32> <i32 1, i32 0>
821-
; CHECK-NEXT: [[R:%.*]] = call <2 x float> @llvm.fma.v2f32(<2 x float> <float 1.000000e+00, float 2.000000e+00>, <2 x float> <float 1.000000e+00, float 2.000000e+00>, <2 x float> [[A]])
822-
; CHECK-NEXT: ret <2 x float> [[R]]
819+
; CHECK-NEXT: [[X:%.*]] = call <2 x float> @llvm.fma.v2f32(<2 x float> [[X1:%.*]], <2 x float> <float 2.000000e+00, float 1.000000e+00>, <2 x float> [[X1]])
820+
; CHECK-NEXT: [[A:%.*]] = shufflevector <2 x float> [[X]], <2 x float> poison, <2 x i32> <i32 1, i32 0>
821+
; CHECK-NEXT: ret <2 x float> [[A]]
823822
;
824823
%a = shufflevector <2 x float> %x, <2 x float> poison, <2 x i32> <i32 1, i32 0>
825824
%r = call <2 x float> @llvm.fma(<2 x float> <float 1.0, float 2.0>, <2 x float> <float 1.0, float 2.0>, <2 x float> %a)
@@ -828,10 +827,9 @@ define <2 x float> @fma_unary_shuffle_ops_2_const(<2 x float> %x) {
828827

829828
define <vscale x 2 x float> @fma_unary_shuffle_ops_1_const_scalable(<vscale x 2 x float> %x, <vscale x 2 x float> %y) {
830829
; CHECK-LABEL: @fma_unary_shuffle_ops_1_const_scalable(
831-
; CHECK-NEXT: [[A:%.*]] = shufflevector <vscale x 2 x float> [[X:%.*]], <vscale x 2 x float> poison, <vscale x 2 x i32> zeroinitializer
832-
; CHECK-NEXT: [[B:%.*]] = shufflevector <vscale x 2 x float> [[Y:%.*]], <vscale x 2 x float> poison, <vscale x 2 x i32> zeroinitializer
833-
; CHECK-NEXT: [[R:%.*]] = call <vscale x 2 x float> @llvm.fma.nxv2f32(<vscale x 2 x float> [[A]], <vscale x 2 x float> splat (float 4.200000e+01), <vscale x 2 x float> [[B]])
834-
; CHECK-NEXT: ret <vscale x 2 x float> [[R]]
830+
; CHECK-NEXT: [[R:%.*]] = call <vscale x 2 x float> @llvm.fma.nxv2f32(<vscale x 2 x float> [[A:%.*]], <vscale x 2 x float> splat (float 4.200000e+01), <vscale x 2 x float> [[B:%.*]])
831+
; CHECK-NEXT: [[R1:%.*]] = shufflevector <vscale x 2 x float> [[R]], <vscale x 2 x float> poison, <vscale x 2 x i32> zeroinitializer
832+
; CHECK-NEXT: ret <vscale x 2 x float> [[R1]]
835833
;
836834
%a = shufflevector <vscale x 2 x float> %x, <vscale x 2 x float> poison, <vscale x 2 x i32> zeroinitializer
837835
%b = shufflevector <vscale x 2 x float> %y, <vscale x 2 x float> poison, <vscale x 2 x i32> zeroinitializer
@@ -841,9 +839,9 @@ define <vscale x 2 x float> @fma_unary_shuffle_ops_1_const_scalable(<vscale x 2
841839

842840
define <vscale x 2 x float> @fma_unary_shuffle_ops_2_const_scalable(<vscale x 2 x float> %x) {
843841
; CHECK-LABEL: @fma_unary_shuffle_ops_2_const_scalable(
844-
; CHECK-NEXT: [[A:%.*]] = shufflevector <vscale x 2 x float> [[X:%.*]], <vscale x 2 x float> poison, <vscale x 2 x i32> zeroinitializer
845-
; CHECK-NEXT: [[R:%.*]] = call <vscale x 2 x float> @llvm.fma.nxv2f32(<vscale x 2 x float> splat (float 4.200000e+01), <vscale x 2 x float> splat (float 4.200000e+01), <vscale x 2 x float> [[A]])
846-
; CHECK-NEXT: ret <vscale x 2 x float> [[R]]
842+
; CHECK-NEXT: [[X:%.*]] = call <vscale x 2 x float> @llvm.fma.nxv2f32(<vscale x 2 x float> [[X1:%.*]], <vscale x 2 x float> splat (float 4.200000e+01), <vscale x 2 x float> [[X1]])
843+
; CHECK-NEXT: [[A:%.*]] = shufflevector <vscale x 2 x float> [[X]], <vscale x 2 x float> poison, <vscale x 2 x i32> zeroinitializer
844+
; CHECK-NEXT: ret <vscale x 2 x float> [[A]]
847845
;
848846
%a = shufflevector <vscale x 2 x float> %x, <vscale x 2 x float> poison, <vscale x 2 x i32> zeroinitializer
849847
%r = call <vscale x 2 x float> @llvm.fma(<vscale x 2 x float> splat (float 42.0), <vscale x 2 x float> splat (float 42.0), <vscale x 2 x float> %a)
@@ -854,9 +852,9 @@ define <3 x float> @fma_unary_shuffle_ops_widening_1_const(<2 x float> %x, <2 x
854852
; CHECK-LABEL: @fma_unary_shuffle_ops_widening_1_const(
855853
; CHECK-NEXT: [[A:%.*]] = shufflevector <2 x float> [[X:%.*]], <2 x float> poison, <3 x i32> <i32 1, i32 0, i32 poison>
856854
; CHECK-NEXT: call void @use_vec3(<3 x float> [[A]])
857-
; CHECK-NEXT: [[B:%.*]] = shufflevector <2 x float> [[Y:%.*]], <2 x float> poison, <3 x i32> <i32 1, i32 0, i32 poison>
858-
; CHECK-NEXT: [[R:%.*]] = call fast <3 x float> @llvm.fma.v3f32(<3 x float> [[A]], <3 x float> splat (float 4.200000e+01), <3 x float> [[B]])
859-
; CHECK-NEXT: ret <3 x float> [[R]]
855+
; CHECK-NEXT: [[Y:%.*]] = call fast <2 x float> @llvm.fma.v2f32(<2 x float> [[X]], <2 x float> splat (float 4.200000e+01), <2 x float> [[Y1:%.*]])
856+
; CHECK-NEXT: [[B:%.*]] = shufflevector <2 x float> [[Y]], <2 x float> poison, <3 x i32> <i32 1, i32 0, i32 poison>
857+
; CHECK-NEXT: ret <3 x float> [[B]]
860858
;
861859
%a = shufflevector <2 x float> %x, <2 x float> poison, <3 x i32> <i32 1, i32 0, i32 poison>
862860
call void @use_vec3(<3 x float> %a)

llvm/test/Transforms/InstCombine/fsh.ll

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -932,10 +932,9 @@ define <2 x i31> @fsh_unary_shuffle_ops_narrowing(<3 x i31> %x, <3 x i31> %y, <3
932932

933933
define <2 x i32> @fsh_unary_shuffle_ops_1_const(<2 x i32> %x, <2 x i32> %y) {
934934
; CHECK-LABEL: @fsh_unary_shuffle_ops_1_const(
935-
; CHECK-NEXT: [[A:%.*]] = shufflevector <2 x i32> [[X:%.*]], <2 x i32> poison, <2 x i32> <i32 1, i32 0>
936-
; CHECK-NEXT: [[B:%.*]] = shufflevector <2 x i32> [[Y:%.*]], <2 x i32> poison, <2 x i32> <i32 1, i32 0>
937-
; CHECK-NEXT: [[R:%.*]] = call <2 x i32> @llvm.fshr.v2i32(<2 x i32> <i32 1, i32 2>, <2 x i32> [[A]], <2 x i32> [[B]])
938-
; CHECK-NEXT: ret <2 x i32> [[R]]
935+
; CHECK-NEXT: [[Y:%.*]] = call <2 x i32> @llvm.fshr.v2i32(<2 x i32> [[X:%.*]], <2 x i32> [[X]], <2 x i32> [[Y1:%.*]])
936+
; CHECK-NEXT: [[B:%.*]] = shufflevector <2 x i32> [[Y]], <2 x i32> poison, <2 x i32> <i32 1, i32 0>
937+
; CHECK-NEXT: ret <2 x i32> [[B]]
939938
;
940939
%a = shufflevector <2 x i32> %x, <2 x i32> poison, <2 x i32> <i32 1, i32 0>
941940
%b = shufflevector <2 x i32> %y, <2 x i32> poison, <2 x i32> <i32 1, i32 0>
@@ -945,9 +944,9 @@ define <2 x i32> @fsh_unary_shuffle_ops_1_const(<2 x i32> %x, <2 x i32> %y) {
945944

946945
define <2 x i32> @fsh_unary_shuffle_ops_2_const(<2 x i32> %x) {
947946
; CHECK-LABEL: @fsh_unary_shuffle_ops_2_const(
948-
; CHECK-NEXT: [[A:%.*]] = shufflevector <2 x i32> [[X:%.*]], <2 x i32> poison, <2 x i32> <i32 1, i32 0>
949-
; CHECK-NEXT: [[R:%.*]] = call <2 x i32> @llvm.fshr.v2i32(<2 x i32> <i32 1, i32 2>, <2 x i32> <i32 1, i32 2>, <2 x i32> [[A]])
950-
; CHECK-NEXT: ret <2 x i32> [[R]]
947+
; CHECK-NEXT: [[X:%.*]] = call <2 x i32> @llvm.fshr.v2i32(<2 x i32> [[X1:%.*]], <2 x i32> <i32 2, i32 1>, <2 x i32> [[X1]])
948+
; CHECK-NEXT: [[A:%.*]] = shufflevector <2 x i32> [[X]], <2 x i32> poison, <2 x i32> <i32 1, i32 0>
949+
; CHECK-NEXT: ret <2 x i32> [[A]]
951950
;
952951
%a = shufflevector <2 x i32> %x, <2 x i32> poison, <2 x i32> <i32 1, i32 0>
953952
%r = call <2 x i32> @llvm.fshr(<2 x i32> <i32 1, i32 2>, <2 x i32> <i32 1, i32 2>, <2 x i32> %a)
@@ -956,10 +955,9 @@ define <2 x i32> @fsh_unary_shuffle_ops_2_const(<2 x i32> %x) {
956955

957956
define <vscale x 2 x i32> @fsh_unary_shuffle_ops_1_const_scalable(<vscale x 2 x i32> %x, <vscale x 2 x i32> %y) {
958957
; CHECK-LABEL: @fsh_unary_shuffle_ops_1_const_scalable(
959-
; CHECK-NEXT: [[A:%.*]] = shufflevector <vscale x 2 x i32> [[X:%.*]], <vscale x 2 x i32> poison, <vscale x 2 x i32> zeroinitializer
960-
; CHECK-NEXT: [[B:%.*]] = shufflevector <vscale x 2 x i32> [[Y:%.*]], <vscale x 2 x i32> poison, <vscale x 2 x i32> zeroinitializer
961-
; CHECK-NEXT: [[R:%.*]] = call <vscale x 2 x i32> @llvm.fshr.nxv2i32(<vscale x 2 x i32> splat (i32 42), <vscale x 2 x i32> [[A]], <vscale x 2 x i32> [[B]])
962-
; CHECK-NEXT: ret <vscale x 2 x i32> [[R]]
958+
; CHECK-NEXT: [[Y:%.*]] = call <vscale x 2 x i32> @llvm.fshr.nxv2i32(<vscale x 2 x i32> [[X:%.*]], <vscale x 2 x i32> [[X]], <vscale x 2 x i32> [[Y1:%.*]])
959+
; CHECK-NEXT: [[B:%.*]] = shufflevector <vscale x 2 x i32> [[Y]], <vscale x 2 x i32> poison, <vscale x 2 x i32> zeroinitializer
960+
; CHECK-NEXT: ret <vscale x 2 x i32> [[B]]
963961
;
964962
%a = shufflevector <vscale x 2 x i32> %x, <vscale x 2 x i32> poison, <vscale x 2 x i32> zeroinitializer
965963
%b = shufflevector <vscale x 2 x i32> %y, <vscale x 2 x i32> poison, <vscale x 2 x i32> zeroinitializer
@@ -969,9 +967,9 @@ define <vscale x 2 x i32> @fsh_unary_shuffle_ops_1_const_scalable(<vscale x 2 x
969967

970968
define <vscale x 2 x i32> @fsh_unary_shuffle_ops_2_const_scalable(<vscale x 2 x i32> %x) {
971969
; CHECK-LABEL: @fsh_unary_shuffle_ops_2_const_scalable(
972-
; CHECK-NEXT: [[A:%.*]] = shufflevector <vscale x 2 x i32> [[X:%.*]], <vscale x 2 x i32> poison, <vscale x 2 x i32> zeroinitializer
973-
; CHECK-NEXT: [[R:%.*]] = call <vscale x 2 x i32> @llvm.fshr.nxv2i32(<vscale x 2 x i32> splat (i32 42), <vscale x 2 x i32> splat (i32 42), <vscale x 2 x i32> [[A]])
974-
; CHECK-NEXT: ret <vscale x 2 x i32> [[R]]
970+
; CHECK-NEXT: [[X:%.*]] = call <vscale x 2 x i32> @llvm.fshr.nxv2i32(<vscale x 2 x i32> [[X1:%.*]], <vscale x 2 x i32> splat (i32 42), <vscale x 2 x i32> [[X1]])
971+
; CHECK-NEXT: [[A:%.*]] = shufflevector <vscale x 2 x i32> [[X]], <vscale x 2 x i32> poison, <vscale x 2 x i32> zeroinitializer
972+
; CHECK-NEXT: ret <vscale x 2 x i32> [[A]]
975973
;
976974
%a = shufflevector <vscale x 2 x i32> %x, <vscale x 2 x i32> poison, <vscale x 2 x i32> zeroinitializer
977975
%r = call <vscale x 2 x i32> @llvm.fshr(<vscale x 2 x i32> splat (i32 42), <vscale x 2 x i32> splat (i32 42), <vscale x 2 x i32> %a)
@@ -982,9 +980,9 @@ define <3 x i32> @fsh_unary_shuffle_ops_widening_1_const(<2 x i32> %x, <2 x i32>
982980
; CHECK-LABEL: @fsh_unary_shuffle_ops_widening_1_const(
983981
; CHECK-NEXT: [[A:%.*]] = shufflevector <2 x i32> [[X:%.*]], <2 x i32> poison, <3 x i32> <i32 1, i32 0, i32 poison>
984982
; CHECK-NEXT: call void @use_v3(<3 x i32> [[A]])
985-
; CHECK-NEXT: [[B:%.*]] = shufflevector <2 x i32> [[Y:%.*]], <2 x i32> poison, <3 x i32> <i32 1, i32 0, i32 poison>
986-
; CHECK-NEXT: [[R:%.*]] = call <3 x i32> @llvm.fshr.v3i32(<3 x i32> splat (i32 42), <3 x i32> [[A]], <3 x i32> [[B]])
987-
; CHECK-NEXT: ret <3 x i32> [[R]]
983+
; CHECK-NEXT: [[Y:%.*]] = call <2 x i32> @llvm.fshr.v2i32(<2 x i32> [[X]], <2 x i32> [[X]], <2 x i32> [[Y1:%.*]])
984+
; CHECK-NEXT: [[B:%.*]] = shufflevector <2 x i32> [[Y]], <2 x i32> poison, <3 x i32> <i32 1, i32 0, i32 poison>
985+
; CHECK-NEXT: ret <3 x i32> [[B]]
988986
;
989987
%a = shufflevector <2 x i32> %x, <2 x i32> poison, <3 x i32> <i32 1, i32 0, i32 poison>
990988
call void @use_v3(<3 x i32> %a)

llvm/test/Transforms/InstCombine/minmax-intrinsics.ll

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2418,9 +2418,9 @@ define <3 x i8> @umin_unary_shuffle_ops_narrowing(<4 x i8> %x, <4 x i8> %y) {
24182418

24192419
define <3 x i8> @smax_unary_shuffle_ops_lhs_const(<3 x i8> %x) {
24202420
; CHECK-LABEL: @smax_unary_shuffle_ops_lhs_const(
2421-
; CHECK-NEXT: [[SX:%.*]] = shufflevector <3 x i8> [[X:%.*]], <3 x i8> poison, <3 x i32> <i32 1, i32 0, i32 2>
2422-
; CHECK-NEXT: [[R:%.*]] = call <3 x i8> @llvm.smax.v3i8(<3 x i8> [[SX]], <3 x i8> <i8 0, i8 1, i8 2>)
2423-
; CHECK-NEXT: ret <3 x i8> [[R]]
2421+
; CHECK-NEXT: [[X:%.*]] = call <3 x i8> @llvm.smax.v3i8(<3 x i8> [[X1:%.*]], <3 x i8> <i8 1, i8 0, i8 2>)
2422+
; CHECK-NEXT: [[SX:%.*]] = shufflevector <3 x i8> [[X]], <3 x i8> poison, <3 x i32> <i32 1, i32 0, i32 2>
2423+
; CHECK-NEXT: ret <3 x i8> [[SX]]
24242424
;
24252425
%sx = shufflevector <3 x i8> %x, <3 x i8> poison, <3 x i32> <i32 1, i32 0, i32 2>
24262426
%r = call <3 x i8> @llvm.smax(<3 x i8> <i8 0, i8 1, i8 2>, <3 x i8> %sx)
@@ -2429,9 +2429,9 @@ define <3 x i8> @smax_unary_shuffle_ops_lhs_const(<3 x i8> %x) {
24292429

24302430
define <vscale x 3 x i8> @smax_unary_shuffle_ops_lhs_const_scalable(<vscale x 3 x i8> %x) {
24312431
; CHECK-LABEL: @smax_unary_shuffle_ops_lhs_const_scalable(
2432-
; CHECK-NEXT: [[SX:%.*]] = shufflevector <vscale x 3 x i8> [[X:%.*]], <vscale x 3 x i8> poison, <vscale x 3 x i32> zeroinitializer
2433-
; CHECK-NEXT: [[R:%.*]] = call <vscale x 3 x i8> @llvm.smax.nxv3i8(<vscale x 3 x i8> [[SX]], <vscale x 3 x i8> splat (i8 42))
2434-
; CHECK-NEXT: ret <vscale x 3 x i8> [[R]]
2432+
; CHECK-NEXT: [[R:%.*]] = call <vscale x 3 x i8> @llvm.smax.nxv3i8(<vscale x 3 x i8> [[SX:%.*]], <vscale x 3 x i8> splat (i8 42))
2433+
; CHECK-NEXT: [[R1:%.*]] = shufflevector <vscale x 3 x i8> [[R]], <vscale x 3 x i8> poison, <vscale x 3 x i32> zeroinitializer
2434+
; CHECK-NEXT: ret <vscale x 3 x i8> [[R1]]
24352435
;
24362436
%sx = shufflevector <vscale x 3 x i8> %x, <vscale x 3 x i8> poison, <vscale x 3 x i32> zeroinitializer
24372437
%r = call <vscale x 3 x i8> @llvm.smax(<vscale x 3 x i8> splat (i8 42), <vscale x 3 x i8> %sx)
@@ -2440,9 +2440,9 @@ define <vscale x 3 x i8> @smax_unary_shuffle_ops_lhs_const_scalable(<vscale x 3
24402440

24412441
define <3 x i8> @smax_unary_shuffle_ops_lhs_const_widening(<2 x i8> %x) {
24422442
; CHECK-LABEL: @smax_unary_shuffle_ops_lhs_const_widening(
2443-
; CHECK-NEXT: [[SX:%.*]] = shufflevector <2 x i8> [[X:%.*]], <2 x i8> poison, <3 x i32> <i32 1, i32 0, i32 poison>
2444-
; CHECK-NEXT: [[R:%.*]] = call <3 x i8> @llvm.smax.v3i8(<3 x i8> [[SX]], <3 x i8> <i8 0, i8 1, i8 2>)
2445-
; CHECK-NEXT: ret <3 x i8> [[R]]
2443+
; CHECK-NEXT: [[X:%.*]] = call <2 x i8> @llvm.smax.v2i8(<2 x i8> [[X1:%.*]], <2 x i8> <i8 1, i8 0>)
2444+
; CHECK-NEXT: [[SX:%.*]] = shufflevector <2 x i8> [[X]], <2 x i8> poison, <3 x i32> <i32 1, i32 0, i32 poison>
2445+
; CHECK-NEXT: ret <3 x i8> [[SX]]
24462446
;
24472447
%sx = shufflevector <2 x i8> %x, <2 x i8> poison, <3 x i32> <i32 1, i32 0, i32 poison>
24482448
%r = call <3 x i8> @llvm.smax(<3 x i8> <i8 0, i8 1, i8 2>, <3 x i8> %sx)

0 commit comments

Comments
 (0)