diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp --- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp +++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp @@ -312,23 +312,49 @@ /// Match a vector binop instruction with inserted scalar operands and convert /// to scalar binop followed by insertelement. static bool scalarizeBinop(Instruction &I, const TargetTransformInfo &TTI) { - Instruction *Ins0, *Ins1; - if (!match(&I, m_BinOp(m_Instruction(Ins0), m_Instruction(Ins1)))) + Value *Ins0, *Ins1; + if (!match(&I, m_BinOp(m_Value(Ins0), m_Value(Ins1)))) return false; + // Match against one or both scalar values being inserted into constant + // vectors: + // vec_bo VecC0, (inselt VecC1, V1, Index) + // vec_bo (inselt VecC0, V0, Index), VecC1 + // vec_bo (inselt VecC0, V0, Index), (inselt VecC1, V1, Index) // TODO: Deal with mismatched index constants and variable indexes? Constant *VecC0, *VecC1; Value *V0, *V1; - uint64_t Index; + uint64_t Index0, Index1; if (!match(Ins0, m_InsertElt(m_Constant(VecC0), m_Value(V0), - m_ConstantInt(Index))) || - !match(Ins1, m_InsertElt(m_Constant(VecC1), m_Value(V1), - m_SpecificInt(Index)))) + m_ConstantInt(Index0)))) { + V0 = nullptr; + if (!match(Ins0, m_Constant(VecC0))) + return false; + } + if (!match(Ins1, m_InsertElt(m_Constant(VecC1), m_Value(V1), + m_ConstantInt(Index1)))) { + V1 = nullptr; + if (!match(Ins1, m_Constant(VecC1))) + return false; + } + if (!V0 && !V1) + return false; + if (V0 && V1 && Index0 != Index1) + return false; + + // Bail for single insertion if its a load. + // TODO: Handle this once getVectorInstrCost can cost for load/stores. + auto *I0 = dyn_cast_or_null(V0); + auto *I1 = dyn_cast_or_null(V1); + if ((!V0 && I1 && I1->mayReadFromMemory()) || + (!V1 && I0 && I0->mayReadFromMemory())) return false; - Type *ScalarTy = V0->getType(); + uint64_t Index = V0 ? Index0 : Index1; + Type *ScalarTy = V0 ? V0->getType() : V1->getType(); Type *VecTy = I.getType(); - assert(VecTy->isVectorTy() && ScalarTy == V1->getType() && + assert(VecTy->isVectorTy() && + (!V0 || !V1 || V0->getType() == V1->getType()) && (ScalarTy->isIntegerTy() || ScalarTy->isFloatingPointTy()) && "Unexpected types for insert into binop"); @@ -340,10 +366,10 @@ // both sequences. int InsertCost = TTI.getVectorInstrCost(Instruction::InsertElement, VecTy, Index); - int OldCost = InsertCost + InsertCost + VectorOpCost; + int OldCost = (V0 ? InsertCost : 0) + (V1 ? InsertCost : 0) + VectorOpCost; int NewCost = ScalarOpCost + InsertCost + - !Ins0->hasOneUse() * InsertCost + - !Ins1->hasOneUse() * InsertCost; + (V0 ? !Ins0->hasOneUse() * InsertCost : 0) + + (V1 ? !Ins1->hasOneUse() * InsertCost : 0); // We want to scalarize unless the vector variant actually has lower cost. if (OldCost < NewCost) @@ -353,6 +379,19 @@ // inselt NewVecC, (scalar_bo V0, V1), Index ++NumScalarBO; IRBuilder<> Builder(&I); + + // For constant cases, extract the scalar element, this should constant fold. + if (!V0) { + V0 = Builder.CreateExtractElement(VecC0, Index); + if (!isa_and_nonnull(V0)) + return false; + } + if (!V1) { + V1 = Builder.CreateExtractElement(VecC1, Index); + if (!isa_and_nonnull(V1)) + return false; + } + Value *Scalar = Builder.CreateBinOp(Opcode, V0, V1, I.getName() + ".scalar"); // All IR flags are safe to back-propagate. There is no potential for extra diff --git a/llvm/test/Transforms/PhaseOrdering/X86/scalarization.ll b/llvm/test/Transforms/PhaseOrdering/X86/scalarization.ll --- a/llvm/test/Transforms/PhaseOrdering/X86/scalarization.ll +++ b/llvm/test/Transforms/PhaseOrdering/X86/scalarization.ll @@ -12,31 +12,24 @@ define <4 x i32> @square(<4 x i32> %num, i32 %y, i32 %x, i32 %h, i32 %k, i32 %w, i32 %p, i32 %j, i32 %u) { ; CHECK-LABEL: @square( ; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[K:%.*]], 2 -; CHECK-NEXT: [[SPLATINSERT:%.*]] = insertelement <4 x i32> undef, i32 [[DIV]], i32 0 ; CHECK-NEXT: [[MUL:%.*]] = mul nsw i32 [[P:%.*]], 6234 -; CHECK-NEXT: [[SPLATINSERT2:%.*]] = insertelement <4 x i32> undef, i32 [[MUL]], i32 0 ; CHECK-NEXT: [[MUL5:%.*]] = mul nsw i32 [[H:%.*]], 75 -; CHECK-NEXT: [[SPLATINSERT6:%.*]] = insertelement <4 x i32> undef, i32 [[MUL5]], i32 0 ; CHECK-NEXT: [[DIV9:%.*]] = sdiv i32 [[J:%.*]], 3452 -; CHECK-NEXT: [[SPLATINSERT10:%.*]] = insertelement <4 x i32> undef, i32 [[DIV9]], i32 0 ; CHECK-NEXT: [[MUL13:%.*]] = mul nsw i32 [[W:%.*]], 53 -; CHECK-NEXT: [[SPLATINSERT14:%.*]] = insertelement <4 x i32> undef, i32 [[MUL13]], i32 0 ; CHECK-NEXT: [[DIV17:%.*]] = sdiv i32 [[X:%.*]], 820 -; CHECK-NEXT: [[SPLATINSERT18:%.*]] = insertelement <4 x i32> undef, i32 [[DIV17]], i32 0 ; CHECK-NEXT: [[MUL21:%.*]] = shl nsw i32 [[U:%.*]], 2 -; CHECK-NEXT: [[SPLATINSERT22:%.*]] = insertelement <4 x i32> undef, i32 [[MUL21]], i32 0 -; CHECK-NEXT: [[SPLATINSERT25:%.*]] = insertelement <4 x i32> undef, i32 [[Y:%.*]], i32 0 -; CHECK-NEXT: [[TMP1:%.*]] = add <4 x i32> [[SPLATINSERT25]], -; CHECK-NEXT: [[TMP2:%.*]] = add <4 x i32> [[TMP1]], [[SPLATINSERT18]] -; CHECK-NEXT: [[TMP3:%.*]] = add <4 x i32> [[TMP2]], [[SPLATINSERT6]] -; CHECK-NEXT: [[TMP4:%.*]] = add <4 x i32> [[TMP3]], [[SPLATINSERT]] -; CHECK-NEXT: [[TMP5:%.*]] = add <4 x i32> [[TMP4]], [[SPLATINSERT14]] -; CHECK-NEXT: [[TMP6:%.*]] = add <4 x i32> [[TMP5]], [[SPLATINSERT2]] -; CHECK-NEXT: [[TMP7:%.*]] = add <4 x i32> [[TMP6]], [[SPLATINSERT10]] -; CHECK-NEXT: [[TMP8:%.*]] = add <4 x i32> [[TMP7]], [[SPLATINSERT22]] -; CHECK-NEXT: [[TMP9:%.*]] = add <4 x i32> [[TMP8]], -; CHECK-NEXT: [[TMP10:%.*]] = shufflevector <4 x i32> [[TMP9]], <4 x i32> undef, <4 x i32> zeroinitializer -; CHECK-NEXT: [[ADD29:%.*]] = add <4 x i32> [[TMP10]], [[NUM:%.*]] +; CHECK-NEXT: [[DOTSCALAR:%.*]] = add i32 [[Y:%.*]], 1 +; CHECK-NEXT: [[DOTSCALAR1:%.*]] = add i32 [[DOTSCALAR]], [[DIV17]] +; CHECK-NEXT: [[DOTSCALAR2:%.*]] = add i32 [[DOTSCALAR1]], [[MUL5]] +; CHECK-NEXT: [[DOTSCALAR3:%.*]] = add i32 [[DOTSCALAR2]], [[DIV]] +; CHECK-NEXT: [[DOTSCALAR4:%.*]] = add i32 [[DOTSCALAR3]], [[MUL13]] +; CHECK-NEXT: [[DOTSCALAR5:%.*]] = add i32 [[DOTSCALAR4]], [[MUL]] +; CHECK-NEXT: [[DOTSCALAR6:%.*]] = add i32 [[DOTSCALAR5]], [[DIV9]] +; CHECK-NEXT: [[DOTSCALAR7:%.*]] = add i32 [[DOTSCALAR6]], [[MUL21]] +; CHECK-NEXT: [[DOTSCALAR8:%.*]] = add i32 [[DOTSCALAR7]], 317425 +; CHECK-NEXT: [[TMP1:%.*]] = insertelement <4 x i32> undef, i32 [[DOTSCALAR8]], i64 0 +; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <4 x i32> [[TMP1]], <4 x i32> undef, <4 x i32> zeroinitializer +; CHECK-NEXT: [[ADD29:%.*]] = add <4 x i32> [[TMP2]], [[NUM:%.*]] ; CHECK-NEXT: ret <4 x i32> [[ADD29]] ; %add = add <4 x i32> %num, diff --git a/llvm/test/Transforms/VectorCombine/X86/insert-binop-with-constant.ll b/llvm/test/Transforms/VectorCombine/X86/insert-binop-with-constant.ll --- a/llvm/test/Transforms/VectorCombine/X86/insert-binop-with-constant.ll +++ b/llvm/test/Transforms/VectorCombine/X86/insert-binop-with-constant.ll @@ -4,8 +4,8 @@ define <2 x i64> @add_constant(i64 %x) { ; CHECK-LABEL: @add_constant( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = add <2 x i64> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = add i64 [[X:%.*]], 42 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 0 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 0 @@ -15,8 +15,8 @@ define <2 x i64> @add_constant_not_undef_lane(i64 %x) { ; CHECK-LABEL: @add_constant_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = add <2 x i64> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = add i64 [[X:%.*]], 42 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 0 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 0 @@ -24,12 +24,25 @@ ret <2 x i64> %bo } +define <2 x i64> @add_constant_load(i64* %p) { +; CHECK-LABEL: @add_constant_load( +; CHECK-NEXT: [[LD:%.*]] = load i64, i64* [[P:%.*]], align 4 +; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[LD]], i32 0 +; CHECK-NEXT: [[BO:%.*]] = add <2 x i64> [[INS]], +; CHECK-NEXT: ret <2 x i64> [[BO]] +; + %ld = load i64, i64* %p + %ins = insertelement <2 x i64> undef, i64 %ld, i32 0 + %bo = add <2 x i64> %ins, + ret <2 x i64> %bo +} + ; IR flags are not required, but they should propagate. define <4 x i32> @sub_constant_op0(i32 %x) { ; CHECK-LABEL: @sub_constant_op0( -; CHECK-NEXT: [[INS:%.*]] = insertelement <4 x i32> undef, i32 [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = sub nuw nsw <4 x i32> , [[INS]] +; CHECK-NEXT: [[BO_SCALAR:%.*]] = sub nuw nsw i32 -42, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <4 x i32> undef, i32 [[BO_SCALAR]], i64 1 ; CHECK-NEXT: ret <4 x i32> [[BO]] ; %ins = insertelement <4 x i32> undef, i32 %x, i32 1 @@ -39,8 +52,8 @@ define <4 x i32> @sub_constant_op0_not_undef_lane(i32 %x) { ; CHECK-LABEL: @sub_constant_op0_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <4 x i32> undef, i32 [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = sub nuw <4 x i32> , [[INS]] +; CHECK-NEXT: [[BO_SCALAR:%.*]] = sub nuw i32 42, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <4 x i32> undef, i32 [[BO_SCALAR]], i64 1 ; CHECK-NEXT: ret <4 x i32> [[BO]] ; %ins = insertelement <4 x i32> undef, i32 %x, i32 1 @@ -50,8 +63,8 @@ define <8 x i16> @sub_constant_op1(i16 %x) { ; CHECK-LABEL: @sub_constant_op1( -; CHECK-NEXT: [[INS:%.*]] = insertelement <8 x i16> undef, i16 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = sub nuw <8 x i16> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = sub nuw i16 [[X:%.*]], 42 +; CHECK-NEXT: [[BO:%.*]] = insertelement <8 x i16> undef, i16 [[BO_SCALAR]], i64 0 ; CHECK-NEXT: ret <8 x i16> [[BO]] ; %ins = insertelement <8 x i16> undef, i16 %x, i32 0 @@ -61,8 +74,8 @@ define <8 x i16> @sub_constant_op1_not_undef_lane(i16 %x) { ; CHECK-LABEL: @sub_constant_op1_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <8 x i16> undef, i16 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = sub nuw <8 x i16> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = sub nuw i16 [[X:%.*]], 42 +; CHECK-NEXT: [[BO:%.*]] = insertelement <8 x i16> undef, i16 [[BO_SCALAR]], i64 0 ; CHECK-NEXT: ret <8 x i16> [[BO]] ; %ins = insertelement <8 x i16> undef, i16 %x, i32 0 @@ -72,8 +85,8 @@ define <16 x i8> @mul_constant(i8 %x) { ; CHECK-LABEL: @mul_constant( -; CHECK-NEXT: [[INS:%.*]] = insertelement <16 x i8> undef, i8 [[X:%.*]], i32 2 -; CHECK-NEXT: [[BO:%.*]] = mul <16 x i8> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = mul i8 [[X:%.*]], -42 +; CHECK-NEXT: [[BO:%.*]] = insertelement <16 x i8> , i8 [[BO_SCALAR]], i64 2 ; CHECK-NEXT: ret <16 x i8> [[BO]] ; %ins = insertelement <16 x i8> undef, i8 %x, i32 2 @@ -83,8 +96,8 @@ define <3 x i64> @mul_constant_not_undef_lane(i64 %x) { ; CHECK-LABEL: @mul_constant_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <3 x i64> undef, i64 [[X:%.*]], i32 2 -; CHECK-NEXT: [[BO:%.*]] = mul <3 x i64> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = mul i64 [[X:%.*]], -42 +; CHECK-NEXT: [[BO:%.*]] = insertelement <3 x i64> , i64 [[BO_SCALAR]], i64 2 ; CHECK-NEXT: ret <3 x i64> [[BO]] ; %ins = insertelement <3 x i64> undef, i64 %x, i32 2 @@ -94,8 +107,8 @@ define <2 x i64> @shl_constant_op0(i64 %x) { ; CHECK-LABEL: @shl_constant_op0( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = shl <2 x i64> , [[INS]] +; CHECK-NEXT: [[BO_SCALAR:%.*]] = shl i64 2, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 1 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 1 @@ -105,8 +118,8 @@ define <2 x i64> @shl_constant_op0_not_undef_lane(i64 %x) { ; CHECK-LABEL: @shl_constant_op0_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = shl <2 x i64> , [[INS]] +; CHECK-NEXT: [[BO_SCALAR:%.*]] = shl i64 2, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 1 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 1 @@ -114,10 +127,23 @@ ret <2 x i64> %bo } +define <2 x i64> @shl_constant_op0_load(i64* %p) { +; CHECK-LABEL: @shl_constant_op0_load( +; CHECK-NEXT: [[LD:%.*]] = load i64, i64* [[P:%.*]], align 4 +; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[LD]], i32 1 +; CHECK-NEXT: [[BO:%.*]] = shl <2 x i64> , [[INS]] +; CHECK-NEXT: ret <2 x i64> [[BO]] +; + %ld = load i64, i64* %p + %ins = insertelement <2 x i64> undef, i64 %ld, i32 1 + %bo = shl <2 x i64> , %ins + ret <2 x i64> %bo +} + define <2 x i64> @shl_constant_op1(i64 %x) { ; CHECK-LABEL: @shl_constant_op1( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = shl nuw <2 x i64> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = shl nuw i64 [[X:%.*]], 5 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> , i64 [[BO_SCALAR]], i64 0 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 0 @@ -127,8 +153,8 @@ define <2 x i64> @shl_constant_op1_not_undef_lane(i64 %x) { ; CHECK-LABEL: @shl_constant_op1_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = shl nuw <2 x i64> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = shl nuw i64 [[X:%.*]], 5 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> zeroinitializer, i64 [[BO_SCALAR]], i64 0 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 0 @@ -136,10 +162,23 @@ ret <2 x i64> %bo } +define <2 x i64> @shl_constant_op1_load(i64* %p) { +; CHECK-LABEL: @shl_constant_op1_load( +; CHECK-NEXT: [[LD:%.*]] = load i64, i64* [[P:%.*]], align 4 +; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[LD]], i32 0 +; CHECK-NEXT: [[BO:%.*]] = shl nuw <2 x i64> [[INS]], +; CHECK-NEXT: ret <2 x i64> [[BO]] +; + %ld = load i64, i64* %p + %ins = insertelement <2 x i64> undef, i64 %ld, i32 0 + %bo = shl nuw <2 x i64> %ins, + ret <2 x i64> %bo +} + define <2 x i64> @ashr_constant_op0(i64 %x) { ; CHECK-LABEL: @ashr_constant_op0( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = ashr exact <2 x i64> , [[INS]] +; CHECK-NEXT: [[BO_SCALAR:%.*]] = ashr exact i64 2, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 1 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 1 @@ -149,8 +188,8 @@ define <2 x i64> @ashr_constant_op0_not_undef_lane(i64 %x) { ; CHECK-LABEL: @ashr_constant_op0_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = ashr exact <2 x i64> , [[INS]] +; CHECK-NEXT: [[BO_SCALAR:%.*]] = ashr exact i64 2, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 1 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 1 @@ -160,8 +199,8 @@ define <2 x i64> @ashr_constant_op1(i64 %x) { ; CHECK-LABEL: @ashr_constant_op1( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = ashr <2 x i64> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = ashr i64 [[X:%.*]], 5 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> , i64 [[BO_SCALAR]], i64 0 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 0 @@ -171,8 +210,8 @@ define <2 x i64> @ashr_constant_op1_not_undef_lane(i64 %x) { ; CHECK-LABEL: @ashr_constant_op1_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = ashr <2 x i64> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = ashr i64 [[X:%.*]], 5 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> zeroinitializer, i64 [[BO_SCALAR]], i64 0 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 0 @@ -182,8 +221,8 @@ define <2 x i64> @lshr_constant_op0(i64 %x) { ; CHECK-LABEL: @lshr_constant_op0( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = lshr <2 x i64> , [[INS]] +; CHECK-NEXT: [[BO_SCALAR:%.*]] = lshr i64 5, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 0 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 0 @@ -193,8 +232,8 @@ define <2 x i64> @lshr_constant_op0_not_undef_lane(i64 %x) { ; CHECK-LABEL: @lshr_constant_op0_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = lshr <2 x i64> , [[INS]] +; CHECK-NEXT: [[BO_SCALAR:%.*]] = lshr i64 5, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 0 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 0 @@ -204,8 +243,8 @@ define <2 x i64> @lshr_constant_op1(i64 %x) { ; CHECK-LABEL: @lshr_constant_op1( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = lshr exact <2 x i64> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = lshr exact i64 [[X:%.*]], 2 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> , i64 [[BO_SCALAR]], i64 1 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 1 @@ -215,8 +254,8 @@ define <2 x i64> @lshr_constant_op1_not_undef_lane(i64 %x) { ; CHECK-LABEL: @lshr_constant_op1_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = lshr exact <2 x i64> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = lshr exact i64 [[X:%.*]], 2 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> zeroinitializer, i64 [[BO_SCALAR]], i64 1 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 1 @@ -226,8 +265,8 @@ define <2 x i64> @urem_constant_op0(i64 %x) { ; CHECK-LABEL: @urem_constant_op0( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = urem <2 x i64> , [[INS]] +; CHECK-NEXT: [[BO_SCALAR:%.*]] = urem i64 5, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 0 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 0 @@ -237,8 +276,8 @@ define <2 x i64> @urem_constant_op0_not_undef_lane(i64 %x) { ; CHECK-LABEL: @urem_constant_op0_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = urem <2 x i64> , [[INS]] +; CHECK-NEXT: [[BO_SCALAR:%.*]] = urem i64 5, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 0 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 0 @@ -248,8 +287,8 @@ define <2 x i64> @urem_constant_op1(i64 %x) { ; CHECK-LABEL: @urem_constant_op1( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = urem <2 x i64> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = urem i64 [[X:%.*]], 2 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> , i64 [[BO_SCALAR]], i64 1 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 1 @@ -259,8 +298,8 @@ define <2 x i64> @urem_constant_op1_not_undef_lane(i64 %x) { ; CHECK-LABEL: @urem_constant_op1_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = urem <2 x i64> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = urem i64 [[X:%.*]], 2 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> zeroinitializer, i64 [[BO_SCALAR]], i64 1 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 1 @@ -270,8 +309,8 @@ define <2 x i64> @srem_constant_op0(i64 %x) { ; CHECK-LABEL: @srem_constant_op0( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = srem <2 x i64> , [[INS]] +; CHECK-NEXT: [[BO_SCALAR:%.*]] = srem i64 5, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 0 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 0 @@ -281,8 +320,8 @@ define <2 x i64> @srem_constant_op0_not_undef_lane(i64 %x) { ; CHECK-LABEL: @srem_constant_op0_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = srem <2 x i64> , [[INS]] +; CHECK-NEXT: [[BO_SCALAR:%.*]] = srem i64 5, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 0 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 0 @@ -292,8 +331,8 @@ define <2 x i64> @srem_constant_op1(i64 %x) { ; CHECK-LABEL: @srem_constant_op1( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = srem <2 x i64> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = srem i64 [[X:%.*]], 2 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> , i64 [[BO_SCALAR]], i64 1 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 1 @@ -303,8 +342,8 @@ define <2 x i64> @srem_constant_op1_not_undef_lane(i64 %x) { ; CHECK-LABEL: @srem_constant_op1_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = srem <2 x i64> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = srem i64 [[X:%.*]], 2 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> zeroinitializer, i64 [[BO_SCALAR]], i64 1 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 1 @@ -314,8 +353,8 @@ define <2 x i64> @udiv_constant_op0(i64 %x) { ; CHECK-LABEL: @udiv_constant_op0( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = udiv exact <2 x i64> , [[INS]] +; CHECK-NEXT: [[BO_SCALAR:%.*]] = udiv exact i64 5, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 0 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 0 @@ -325,8 +364,8 @@ define <2 x i64> @udiv_constant_op0_not_undef_lane(i64 %x) { ; CHECK-LABEL: @udiv_constant_op0_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = udiv exact <2 x i64> , [[INS]] +; CHECK-NEXT: [[BO_SCALAR:%.*]] = udiv exact i64 5, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 0 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 0 @@ -336,8 +375,8 @@ define <2 x i64> @udiv_constant_op1(i64 %x) { ; CHECK-LABEL: @udiv_constant_op1( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = udiv <2 x i64> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = udiv i64 [[X:%.*]], 2 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> , i64 [[BO_SCALAR]], i64 1 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 1 @@ -347,8 +386,8 @@ define <2 x i64> @udiv_constant_op1_not_undef_lane(i64 %x) { ; CHECK-LABEL: @udiv_constant_op1_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = udiv <2 x i64> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = udiv i64 [[X:%.*]], 2 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> zeroinitializer, i64 [[BO_SCALAR]], i64 1 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 1 @@ -358,8 +397,8 @@ define <2 x i64> @sdiv_constant_op0(i64 %x) { ; CHECK-LABEL: @sdiv_constant_op0( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = sdiv <2 x i64> , [[INS]] +; CHECK-NEXT: [[BO_SCALAR:%.*]] = sdiv i64 5, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 0 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 0 @@ -369,8 +408,8 @@ define <2 x i64> @sdiv_constant_op0_not_undef_lane(i64 %x) { ; CHECK-LABEL: @sdiv_constant_op0_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = sdiv <2 x i64> , [[INS]] +; CHECK-NEXT: [[BO_SCALAR:%.*]] = sdiv i64 5, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 0 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 0 @@ -380,8 +419,8 @@ define <2 x i64> @sdiv_constant_op1(i64 %x) { ; CHECK-LABEL: @sdiv_constant_op1( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = sdiv exact <2 x i64> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = sdiv exact i64 [[X:%.*]], 2 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> , i64 [[BO_SCALAR]], i64 1 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 1 @@ -391,8 +430,8 @@ define <2 x i64> @sdiv_constant_op1_not_undef_lane(i64 %x) { ; CHECK-LABEL: @sdiv_constant_op1_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = sdiv exact <2 x i64> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = sdiv exact i64 [[X:%.*]], 2 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> zeroinitializer, i64 [[BO_SCALAR]], i64 1 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 1 @@ -402,8 +441,8 @@ define <2 x i64> @and_constant(i64 %x) { ; CHECK-LABEL: @and_constant( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = and <2 x i64> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = and i64 [[X:%.*]], 42 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> , i64 [[BO_SCALAR]], i64 0 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 0 @@ -413,8 +452,8 @@ define <2 x i64> @and_constant_not_undef_lane(i64 %x) { ; CHECK-LABEL: @and_constant_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = and <2 x i64> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = and i64 [[X:%.*]], 42 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> zeroinitializer, i64 [[BO_SCALAR]], i64 0 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 0 @@ -424,8 +463,8 @@ define <2 x i64> @or_constant(i64 %x) { ; CHECK-LABEL: @or_constant( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = or <2 x i64> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = or i64 [[X:%.*]], -42 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> , i64 [[BO_SCALAR]], i64 1 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 1 @@ -435,8 +474,8 @@ define <2 x i64> @or_constant_not_undef_lane(i64 %x) { ; CHECK-LABEL: @or_constant_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = or <2 x i64> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = or i64 [[X:%.*]], -42 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> , i64 [[BO_SCALAR]], i64 1 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 1 @@ -446,8 +485,8 @@ define <2 x i64> @xor_constant(i64 %x) { ; CHECK-LABEL: @xor_constant( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = xor <2 x i64> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = xor i64 [[X:%.*]], 42 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> , i64 [[BO_SCALAR]], i64 0 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 0 @@ -457,8 +496,8 @@ define <2 x i64> @xor_constant_not_undef_lane(i64 %x) { ; CHECK-LABEL: @xor_constant_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = xor <2 x i64> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = xor i64 [[X:%.*]], 42 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 0 ; CHECK-NEXT: ret <2 x i64> [[BO]] ; %ins = insertelement <2 x i64> undef, i64 %x, i32 0 @@ -468,8 +507,8 @@ define <2 x double> @fadd_constant(double %x) { ; CHECK-LABEL: @fadd_constant( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x double> undef, double [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = fadd <2 x double> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = fadd double [[X:%.*]], 4.200000e+01 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x double> , double [[BO_SCALAR]], i64 0 ; CHECK-NEXT: ret <2 x double> [[BO]] ; %ins = insertelement <2 x double> undef, double %x, i32 0 @@ -479,8 +518,8 @@ define <2 x double> @fadd_constant_not_undef_lane(double %x) { ; CHECK-LABEL: @fadd_constant_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x double> undef, double [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = fadd <2 x double> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = fadd double [[X:%.*]], -4.200000e+01 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x double> , double [[BO_SCALAR]], i64 1 ; CHECK-NEXT: ret <2 x double> [[BO]] ; %ins = insertelement <2 x double> undef, double %x, i32 1 @@ -490,8 +529,8 @@ define <2 x double> @fsub_constant_op0(double %x) { ; CHECK-LABEL: @fsub_constant_op0( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x double> undef, double [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = fsub fast <2 x double> , [[INS]] +; CHECK-NEXT: [[BO_SCALAR:%.*]] = fsub fast double 4.200000e+01, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x double> , double [[BO_SCALAR]], i64 0 ; CHECK-NEXT: ret <2 x double> [[BO]] ; %ins = insertelement <2 x double> undef, double %x, i32 0 @@ -501,8 +540,8 @@ define <2 x double> @fsub_constant_op0_not_undef_lane(double %x) { ; CHECK-LABEL: @fsub_constant_op0_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x double> undef, double [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = fsub nsz <2 x double> , [[INS]] +; CHECK-NEXT: [[BO_SCALAR:%.*]] = fsub nsz double -4.200000e+01, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x double> , double [[BO_SCALAR]], i64 1 ; CHECK-NEXT: ret <2 x double> [[BO]] ; %ins = insertelement <2 x double> undef, double %x, i32 1 @@ -512,8 +551,8 @@ define <2 x double> @fsub_constant_op1(double %x) { ; CHECK-LABEL: @fsub_constant_op1( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x double> undef, double [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = fsub <2 x double> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = fsub double [[X:%.*]], 4.200000e+01 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x double> , double [[BO_SCALAR]], i64 1 ; CHECK-NEXT: ret <2 x double> [[BO]] ; %ins = insertelement <2 x double> undef, double %x, i32 1 @@ -523,8 +562,8 @@ define <2 x double> @fsub_constant_op1_not_undef_lane(double %x) { ; CHECK-LABEL: @fsub_constant_op1_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x double> undef, double [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = fsub <2 x double> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = fsub double [[X:%.*]], 4.200000e+01 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x double> , double [[BO_SCALAR]], i64 0 ; CHECK-NEXT: ret <2 x double> [[BO]] ; %ins = insertelement <2 x double> undef, double %x, i32 0 @@ -534,8 +573,8 @@ define <2 x double> @fmul_constant(double %x) { ; CHECK-LABEL: @fmul_constant( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x double> undef, double [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = fmul reassoc <2 x double> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = fmul reassoc double [[X:%.*]], 4.200000e+01 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x double> , double [[BO_SCALAR]], i64 0 ; CHECK-NEXT: ret <2 x double> [[BO]] ; %ins = insertelement <2 x double> undef, double %x, i32 0 @@ -545,8 +584,8 @@ define <2 x double> @fmul_constant_not_undef_lane(double %x) { ; CHECK-LABEL: @fmul_constant_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x double> undef, double [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = fmul <2 x double> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = fmul double [[X:%.*]], -4.200000e+01 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x double> , double [[BO_SCALAR]], i64 1 ; CHECK-NEXT: ret <2 x double> [[BO]] ; %ins = insertelement <2 x double> undef, double %x, i32 1 @@ -556,8 +595,8 @@ define <2 x double> @fdiv_constant_op0(double %x) { ; CHECK-LABEL: @fdiv_constant_op0( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x double> undef, double [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = fdiv nnan <2 x double> , [[INS]] +; CHECK-NEXT: [[BO_SCALAR:%.*]] = fdiv nnan double 4.200000e+01, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x double> , double [[BO_SCALAR]], i64 1 ; CHECK-NEXT: ret <2 x double> [[BO]] ; %ins = insertelement <2 x double> undef, double %x, i32 1 @@ -567,8 +606,8 @@ define <2 x double> @fdiv_constant_op0_not_undef_lane(double %x) { ; CHECK-LABEL: @fdiv_constant_op0_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x double> undef, double [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = fdiv ninf <2 x double> , [[INS]] +; CHECK-NEXT: [[BO_SCALAR:%.*]] = fdiv ninf double 4.200000e+01, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x double> , double [[BO_SCALAR]], i64 0 ; CHECK-NEXT: ret <2 x double> [[BO]] ; %ins = insertelement <2 x double> undef, double %x, i32 0 @@ -578,8 +617,8 @@ define <2 x double> @fdiv_constant_op1(double %x) { ; CHECK-LABEL: @fdiv_constant_op1( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x double> undef, double [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = fdiv <2 x double> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = fdiv double [[X:%.*]], 4.200000e+01 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x double> , double [[BO_SCALAR]], i64 0 ; CHECK-NEXT: ret <2 x double> [[BO]] ; %ins = insertelement <2 x double> undef, double %x, i32 0 @@ -589,8 +628,8 @@ define <2 x double> @fdiv_constant_op1_not_undef_lane(double %x) { ; CHECK-LABEL: @fdiv_constant_op1_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x double> undef, double [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = fdiv <2 x double> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = fdiv double [[X:%.*]], 4.200000e+01 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x double> , double [[BO_SCALAR]], i64 0 ; CHECK-NEXT: ret <2 x double> [[BO]] ; %ins = insertelement <2 x double> undef, double %x, i32 0 @@ -600,8 +639,8 @@ define <2 x double> @frem_constant_op0(double %x) { ; CHECK-LABEL: @frem_constant_op0( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x double> undef, double [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = frem fast <2 x double> , [[INS]] +; CHECK-NEXT: [[BO_SCALAR:%.*]] = frem fast double 4.200000e+01, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x double> , double [[BO_SCALAR]], i64 0 ; CHECK-NEXT: ret <2 x double> [[BO]] ; %ins = insertelement <2 x double> undef, double %x, i32 0 @@ -611,8 +650,8 @@ define <2 x double> @frem_constant_op0_not_undef_lane(double %x) { ; CHECK-LABEL: @frem_constant_op0_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x double> undef, double [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = frem <2 x double> , [[INS]] +; CHECK-NEXT: [[BO_SCALAR:%.*]] = frem double -4.200000e+01, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x double> , double [[BO_SCALAR]], i64 1 ; CHECK-NEXT: ret <2 x double> [[BO]] ; %ins = insertelement <2 x double> undef, double %x, i32 1 @@ -622,8 +661,8 @@ define <2 x double> @frem_constant_op1(double %x) { ; CHECK-LABEL: @frem_constant_op1( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x double> undef, double [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = frem ninf <2 x double> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = frem ninf double [[X:%.*]], 4.200000e+01 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x double> , double [[BO_SCALAR]], i64 1 ; CHECK-NEXT: ret <2 x double> [[BO]] ; %ins = insertelement <2 x double> undef, double %x, i32 1 @@ -633,11 +672,63 @@ define <2 x double> @frem_constant_op1_not_undef_lane(double %x) { ; CHECK-LABEL: @frem_constant_op1_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x double> undef, double [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = frem nnan <2 x double> [[INS]], +; CHECK-NEXT: [[BO_SCALAR:%.*]] = frem nnan double [[X:%.*]], 4.200000e+01 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x double> , double [[BO_SCALAR]], i64 0 ; CHECK-NEXT: ret <2 x double> [[BO]] ; %ins = insertelement <2 x double> undef, double %x, i32 0 %bo = frem nnan <2 x double> %ins, ret <2 x double> %bo } + +define <4 x i32> @PR42174(<4 x i32> %arg, i32 %arg1, i32 %arg2, i32 %arg3, i32 %arg4, i32 %arg5, i32 %arg6, i32 %arg7, i32 %arg8) { +; CHECK-LABEL: @PR42174( +; CHECK-NEXT: [[TMP:%.*]] = sdiv i32 [[ARG4:%.*]], 2 +; CHECK-NEXT: [[TMP10:%.*]] = mul nsw i32 [[ARG6:%.*]], 6234 +; CHECK-NEXT: [[TMP12:%.*]] = mul nsw i32 [[ARG3:%.*]], 75 +; CHECK-NEXT: [[TMP14:%.*]] = sdiv i32 [[ARG7:%.*]], 3452 +; CHECK-NEXT: [[TMP16:%.*]] = mul nsw i32 [[ARG5:%.*]], 53 +; CHECK-NEXT: [[TMP18:%.*]] = sdiv i32 [[ARG2:%.*]], 820 +; CHECK-NEXT: [[TMP20:%.*]] = shl nsw i32 [[ARG8:%.*]], 2 +; CHECK-NEXT: [[TMP23_SCALAR:%.*]] = add i32 [[ARG1:%.*]], 1 +; CHECK-NEXT: [[TMP24_SCALAR:%.*]] = add i32 [[TMP23_SCALAR]], [[TMP18]] +; CHECK-NEXT: [[TMP25_SCALAR:%.*]] = add i32 [[TMP24_SCALAR]], [[TMP12]] +; CHECK-NEXT: [[TMP26_SCALAR:%.*]] = add i32 [[TMP25_SCALAR]], [[TMP]] +; CHECK-NEXT: [[TMP27_SCALAR:%.*]] = add i32 [[TMP26_SCALAR]], [[TMP16]] +; CHECK-NEXT: [[TMP28_SCALAR:%.*]] = add i32 [[TMP27_SCALAR]], [[TMP10]] +; CHECK-NEXT: [[TMP29_SCALAR:%.*]] = add i32 [[TMP28_SCALAR]], [[TMP14]] +; CHECK-NEXT: [[TMP30_SCALAR:%.*]] = add i32 [[TMP29_SCALAR]], [[TMP20]] +; CHECK-NEXT: [[TMP31_SCALAR:%.*]] = add i32 [[TMP30_SCALAR]], 317425 +; CHECK-NEXT: [[TMP31:%.*]] = insertelement <4 x i32> undef, i32 [[TMP31_SCALAR]], i64 0 +; CHECK-NEXT: [[TMP32:%.*]] = shufflevector <4 x i32> [[TMP31]], <4 x i32> undef, <4 x i32> zeroinitializer +; CHECK-NEXT: [[TMP33:%.*]] = add <4 x i32> [[TMP32]], [[ARG:%.*]] +; CHECK-NEXT: ret <4 x i32> [[TMP33]] +; + %tmp = sdiv i32 %arg4, 2 + %tmp9 = insertelement <4 x i32> undef, i32 %tmp, i32 0 + %tmp10 = mul nsw i32 %arg6, 6234 + %tmp11 = insertelement <4 x i32> undef, i32 %tmp10, i32 0 + %tmp12 = mul nsw i32 %arg3, 75 + %tmp13 = insertelement <4 x i32> undef, i32 %tmp12, i32 0 + %tmp14 = sdiv i32 %arg7, 3452 + %tmp15 = insertelement <4 x i32> undef, i32 %tmp14, i32 0 + %tmp16 = mul nsw i32 %arg5, 53 + %tmp17 = insertelement <4 x i32> undef, i32 %tmp16, i32 0 + %tmp18 = sdiv i32 %arg2, 820 + %tmp19 = insertelement <4 x i32> undef, i32 %tmp18, i32 0 + %tmp20 = shl nsw i32 %arg8, 2 + %tmp21 = insertelement <4 x i32> undef, i32 %tmp20, i32 0 + %tmp22 = insertelement <4 x i32> undef, i32 %arg1, i32 0 + %tmp23 = add <4 x i32> %tmp22, + %tmp24 = add <4 x i32> %tmp23, %tmp19 + %tmp25 = add <4 x i32> %tmp24, %tmp13 + %tmp26 = add <4 x i32> %tmp25, %tmp9 + %tmp27 = add <4 x i32> %tmp26, %tmp17 + %tmp28 = add <4 x i32> %tmp27, %tmp11 + %tmp29 = add <4 x i32> %tmp28, %tmp15 + %tmp30 = add <4 x i32> %tmp29, %tmp21 + %tmp31 = add <4 x i32> %tmp30, + %tmp32 = shufflevector <4 x i32> %tmp31, <4 x i32> undef, <4 x i32> zeroinitializer + %tmp33 = add <4 x i32> %tmp32, %arg + ret <4 x i32> %tmp33 +}