Index: lib/Transforms/InstCombine/InstructionCombining.cpp =================================================================== --- lib/Transforms/InstCombine/InstructionCombining.cpp +++ lib/Transforms/InstCombine/InstructionCombining.cpp @@ -1354,6 +1354,33 @@ Instruction *InstCombiner::foldShuffledBinop(BinaryOperator &Inst) { if (!Inst.getType()->isVectorTy()) return nullptr; + // Try to transform scalar insert + vector binop into scalar binop + insert. + BinaryOperator::BinaryOps Opcode = Inst.getOpcode(); + Value *X; + Constant *C; + ConstantInt *Idx; + bool ConstOp1 = isa(Inst.getOperand(1)); + if (match(&Inst, m_c_BinOp( + m_OneUse(m_InsertElement(m_Undef(), m_Value(X), m_ConstantInt(Idx))), + m_Constant(C)))) { + // binop (inselt undef, X, Idx), C --> inselt C', (binop X, EltC), Idx + // binop C, (inselt undef, X, Idx) --> inselt C', (binop EltC, X), Idx + Constant *EltC = C->getAggregateElement(Idx); + Value *NewLHS = ConstOp1 ? X : EltC; + Value *NewRHS = ConstOp1 ? EltC : X; + Value *ScalarOp = Builder.CreateBinOp(Opcode, NewLHS, NewRHS); + if (auto *ScalarBO = dyn_cast(ScalarOp)) + ScalarBO->copyIRFlags(&Inst); + + // The new constant vector that we are inserting into is not necessarily an + // undef vector. It is created by folding the constants in the original + // vector with undef using this binary opcode. + UndefValue *UndefVec = UndefValue::get(Inst.getType()); + Constant *NewVecC = ConstOp1 ? ConstantExpr::get(Opcode, UndefVec, C) + : ConstantExpr::get(Opcode, C, UndefVec); + return InsertElementInst::Create(NewVecC, ScalarOp, Idx); + } + // It may not be safe to reorder shuffles and things like div, urem, etc. // because we may trap when executing those ops on unknown vector elements. // See PR20059. @@ -1366,7 +1393,7 @@ assert(cast(RHS->getType())->getNumElements() == VWidth); auto createBinOpShuffle = [&](Value *X, Value *Y, Constant *M) { - Value *XY = Builder.CreateBinOp(Inst.getOpcode(), X, Y); + Value *XY = Builder.CreateBinOp(Opcode, X, Y); if (auto *BO = dyn_cast(XY)) BO->copyIRFlags(&Inst); return new ShuffleVectorInst(XY, UndefValue::get(XY->getType()), M); @@ -1389,7 +1416,6 @@ // intends to move shuffles closer to other shuffles and binops closer to // other binops, so they can be folded. It may also enable demanded elements // transforms. - Constant *C; if (match(&Inst, m_c_BinOp( m_OneUse(m_ShuffleVector(m_Value(V1), m_Undef(), m_Constant(Mask))), m_Constant(C))) && @@ -1421,14 +1447,13 @@ // It may not be safe to execute a binop on a vector with undef elements // because the entire instruction can be folded to undef or create poison // that did not exist in the original code. - bool ConstOp1 = isa(Inst.getOperand(1)); if (Inst.isIntDivRem() || (Inst.isShift() && ConstOp1)) - NewC = getSafeVectorConstantForBinop(Inst.getOpcode(), NewC, ConstOp1); + NewC = getSafeVectorConstantForBinop(Opcode, NewC, ConstOp1); // Op(shuffle(V1, Mask), C) -> shuffle(Op(V1, NewC), Mask) // Op(C, shuffle(V1, Mask)) -> shuffle(Op(NewC, V1), Mask) - Value *NewLHS = isa(LHS) ? NewC : V1; - Value *NewRHS = isa(LHS) ? V1 : NewC; + Value *NewLHS = ConstOp1 ? V1 : NewC; + Value *NewRHS = ConstOp1 ? NewC : V1; return createBinOpShuffle(NewLHS, NewRHS, Mask); } } Index: test/Transforms/InstCombine/inselt-binop.ll =================================================================== --- test/Transforms/InstCombine/inselt-binop.ll +++ test/Transforms/InstCombine/inselt-binop.ll @@ -3,8 +3,8 @@ define <2 x i8> @add_constant(i8 %x) { ; CHECK-LABEL: @add_constant( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = add <2 x i8> [[INS]], +; CHECK-NEXT: [[TMP1:%.*]] = add i8 [[X:%.*]], 42 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> undef, i8 [[TMP1]], i32 0 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 0 @@ -14,8 +14,8 @@ define <2 x i8> @add_constant_not_undef_lane(i8 %x) { ; CHECK-LABEL: @add_constant_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = add <2 x i8> [[INS]], +; CHECK-NEXT: [[TMP1:%.*]] = add i8 [[X:%.*]], 42 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> undef, i8 [[TMP1]], i32 0 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 0 @@ -27,8 +27,8 @@ define <2 x i8> @sub_constant_op0(i8 %x) { ; CHECK-LABEL: @sub_constant_op0( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = sub nuw nsw <2 x i8> , [[INS]] +; CHECK-NEXT: [[TMP1:%.*]] = sub nuw nsw i8 -42, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> undef, i8 [[TMP1]], i32 1 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 1 @@ -38,8 +38,8 @@ define <2 x i8> @sub_constant_op0_not_undef_lane(i8 %x) { ; CHECK-LABEL: @sub_constant_op0_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = sub nuw <2 x i8> , [[INS]] +; CHECK-NEXT: [[TMP1:%.*]] = sub nuw i8 -42, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> undef, i8 [[TMP1]], i32 1 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 1 @@ -49,8 +49,8 @@ define <2 x i8> @sub_constant_op1(i8 %x) { ; CHECK-LABEL: @sub_constant_op1( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = add <2 x i8> [[INS]], +; CHECK-NEXT: [[TMP1:%.*]] = add i8 [[X:%.*]], -42 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> undef, i8 [[TMP1]], i32 0 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 0 @@ -60,8 +60,8 @@ define <2 x i8> @sub_constant_op1_not_undef_lane(i8 %x) { ; CHECK-LABEL: @sub_constant_op1_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = add <2 x i8> [[INS]], +; CHECK-NEXT: [[TMP1:%.*]] = add i8 [[X:%.*]], -42 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> undef, i8 [[TMP1]], i32 0 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 0 @@ -71,8 +71,8 @@ define <3 x i8> @mul_constant(i8 %x) { ; CHECK-LABEL: @mul_constant( -; CHECK-NEXT: [[INS:%.*]] = insertelement <3 x i8> undef, i8 [[X:%.*]], i32 2 -; CHECK-NEXT: [[BO:%.*]] = mul <3 x i8> [[INS]], +; CHECK-NEXT: [[TMP1:%.*]] = mul i8 [[X:%.*]], -42 +; CHECK-NEXT: [[BO:%.*]] = insertelement <3 x i8> undef, i8 [[TMP1]], i32 2 ; CHECK-NEXT: ret <3 x i8> [[BO]] ; %ins = insertelement <3 x i8> undef, i8 %x, i32 2 @@ -82,8 +82,8 @@ define <3 x i8> @mul_constant_not_undef_lane(i8 %x) { ; CHECK-LABEL: @mul_constant_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <3 x i8> undef, i8 [[X:%.*]], i32 2 -; CHECK-NEXT: [[BO:%.*]] = mul <3 x i8> [[INS]], +; CHECK-NEXT: [[TMP1:%.*]] = mul i8 [[X:%.*]], -42 +; CHECK-NEXT: [[BO:%.*]] = insertelement <3 x i8> , i8 [[TMP1]], i32 2 ; CHECK-NEXT: ret <3 x i8> [[BO]] ; %ins = insertelement <3 x i8> undef, i8 %x, i32 2 @@ -93,8 +93,8 @@ define <2 x i8> @shl_constant_op0(i8 %x) { ; CHECK-LABEL: @shl_constant_op0( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = shl <2 x i8> , [[INS]] +; CHECK-NEXT: [[TMP1:%.*]] = shl i8 2, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> undef, i8 [[TMP1]], i32 1 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 1 @@ -104,8 +104,8 @@ define <2 x i8> @shl_constant_op0_not_undef_lane(i8 %x) { ; CHECK-LABEL: @shl_constant_op0_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = shl <2 x i8> , [[INS]] +; CHECK-NEXT: [[TMP1:%.*]] = shl i8 2, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> undef, i8 [[TMP1]], i32 1 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 1 @@ -115,8 +115,8 @@ define <2 x i8> @shl_constant_op1(i8 %x) { ; CHECK-LABEL: @shl_constant_op1( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = shl nuw <2 x i8> [[INS]], +; CHECK-NEXT: [[TMP1:%.*]] = shl nuw i8 [[X:%.*]], 5 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> undef, i8 [[TMP1]], i32 0 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 0 @@ -126,8 +126,8 @@ define <2 x i8> @shl_constant_op1_not_undef_lane(i8 %x) { ; CHECK-LABEL: @shl_constant_op1_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = shl nuw <2 x i8> [[INS]], +; CHECK-NEXT: [[TMP1:%.*]] = shl nuw i8 [[X:%.*]], 5 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> , i8 [[TMP1]], i32 0 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 0 @@ -137,8 +137,8 @@ define <2 x i8> @ashr_constant_op0(i8 %x) { ; CHECK-LABEL: @ashr_constant_op0( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = ashr exact <2 x i8> , [[INS]] +; CHECK-NEXT: [[TMP1:%.*]] = lshr i8 2, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> undef, i8 [[TMP1]], i32 1 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 1 @@ -148,8 +148,8 @@ define <2 x i8> @ashr_constant_op0_not_undef_lane(i8 %x) { ; CHECK-LABEL: @ashr_constant_op0_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = lshr <2 x i8> , [[INS]] +; CHECK-NEXT: [[TMP1:%.*]] = lshr i8 2, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> undef, i8 [[TMP1]], i32 1 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 1 @@ -159,8 +159,8 @@ define <2 x i8> @ashr_constant_op1(i8 %x) { ; CHECK-LABEL: @ashr_constant_op1( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = ashr <2 x i8> [[INS]], +; CHECK-NEXT: [[TMP1:%.*]] = ashr i8 [[X:%.*]], 5 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> undef, i8 [[TMP1]], i32 0 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 0 @@ -170,8 +170,8 @@ define <2 x i8> @ashr_constant_op1_not_undef_lane(i8 %x) { ; CHECK-LABEL: @ashr_constant_op1_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = ashr <2 x i8> [[INS]], +; CHECK-NEXT: [[TMP1:%.*]] = ashr i8 [[X:%.*]], 5 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> , i8 [[TMP1]], i32 0 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 0 @@ -181,8 +181,8 @@ define <2 x i8> @lshr_constant_op0(i8 %x) { ; CHECK-LABEL: @lshr_constant_op0( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = lshr <2 x i8> , [[INS]] +; CHECK-NEXT: [[TMP1:%.*]] = lshr i8 5, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> undef, i8 [[TMP1]], i32 0 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 0 @@ -192,8 +192,8 @@ define <2 x i8> @lshr_constant_op0_not_undef_lane(i8 %x) { ; CHECK-LABEL: @lshr_constant_op0_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = lshr <2 x i8> , [[INS]] +; CHECK-NEXT: [[TMP1:%.*]] = lshr i8 5, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> undef, i8 [[TMP1]], i32 0 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 0 @@ -203,8 +203,8 @@ define <2 x i8> @lshr_constant_op1(i8 %x) { ; CHECK-LABEL: @lshr_constant_op1( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = lshr exact <2 x i8> [[INS]], +; CHECK-NEXT: [[TMP1:%.*]] = lshr exact i8 [[X:%.*]], 2 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> undef, i8 [[TMP1]], i32 1 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 1 @@ -214,8 +214,8 @@ define <2 x i8> @lshr_constant_op1_not_undef_lane(i8 %x) { ; CHECK-LABEL: @lshr_constant_op1_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = lshr exact <2 x i8> [[INS]], +; CHECK-NEXT: [[TMP1:%.*]] = lshr exact i8 [[X:%.*]], 2 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> , i8 [[TMP1]], i32 1 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 1 @@ -225,8 +225,8 @@ define <2 x i8> @urem_constant_op0(i8 %x) { ; CHECK-LABEL: @urem_constant_op0( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = urem <2 x i8> , [[INS]] +; CHECK-NEXT: [[TMP1:%.*]] = urem i8 5, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> undef, i8 [[TMP1]], i32 0 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 0 @@ -236,8 +236,8 @@ define <2 x i8> @urem_constant_op0_not_undef_lane(i8 %x) { ; CHECK-LABEL: @urem_constant_op0_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = urem <2 x i8> , [[INS]] +; CHECK-NEXT: [[TMP1:%.*]] = urem i8 5, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> undef, i8 [[TMP1]], i32 0 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 0 @@ -256,8 +256,8 @@ define <2 x i8> @urem_constant_op1_not_undef_lane(i8 %x) { ; CHECK-LABEL: @urem_constant_op1_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = urem <2 x i8> [[INS]], +; CHECK-NEXT: [[TMP1:%.*]] = and i8 [[X:%.*]], 1 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> , i8 [[TMP1]], i32 1 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 1 @@ -267,8 +267,8 @@ define <2 x i8> @srem_constant_op0(i8 %x) { ; CHECK-LABEL: @srem_constant_op0( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = srem <2 x i8> , [[INS]] +; CHECK-NEXT: [[TMP1:%.*]] = srem i8 5, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> undef, i8 [[TMP1]], i32 0 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 0 @@ -278,8 +278,8 @@ define <2 x i8> @srem_constant_op0_not_undef_lane(i8 %x) { ; CHECK-LABEL: @srem_constant_op0_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = srem <2 x i8> , [[INS]] +; CHECK-NEXT: [[TMP1:%.*]] = srem i8 5, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> undef, i8 [[TMP1]], i32 0 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 0 @@ -298,8 +298,8 @@ define <2 x i8> @srem_constant_op1_not_undef_lane(i8 %x) { ; CHECK-LABEL: @srem_constant_op1_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = srem <2 x i8> [[INS]], +; CHECK-NEXT: [[TMP1:%.*]] = srem i8 [[X:%.*]], 2 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> , i8 [[TMP1]], i32 1 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 1 @@ -309,8 +309,8 @@ define <2 x i8> @udiv_constant_op0(i8 %x) { ; CHECK-LABEL: @udiv_constant_op0( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = udiv exact <2 x i8> , [[INS]] +; CHECK-NEXT: [[TMP1:%.*]] = udiv exact i8 5, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> undef, i8 [[TMP1]], i32 0 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 0 @@ -320,8 +320,8 @@ define <2 x i8> @udiv_constant_op0_not_undef_lane(i8 %x) { ; CHECK-LABEL: @udiv_constant_op0_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = udiv exact <2 x i8> , [[INS]] +; CHECK-NEXT: [[TMP1:%.*]] = udiv exact i8 5, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> undef, i8 [[TMP1]], i32 0 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 0 @@ -340,8 +340,8 @@ define <2 x i8> @udiv_constant_op1_not_undef_lane(i8 %x) { ; CHECK-LABEL: @udiv_constant_op1_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = udiv <2 x i8> [[INS]], +; CHECK-NEXT: [[TMP1:%.*]] = lshr i8 [[X:%.*]], 1 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> , i8 [[TMP1]], i32 1 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 1 @@ -351,8 +351,8 @@ define <2 x i8> @sdiv_constant_op0(i8 %x) { ; CHECK-LABEL: @sdiv_constant_op0( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = sdiv <2 x i8> , [[INS]] +; CHECK-NEXT: [[TMP1:%.*]] = sdiv i8 5, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> undef, i8 [[TMP1]], i32 0 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 0 @@ -362,8 +362,8 @@ define <2 x i8> @sdiv_constant_op0_not_undef_lane(i8 %x) { ; CHECK-LABEL: @sdiv_constant_op0_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = sdiv <2 x i8> , [[INS]] +; CHECK-NEXT: [[TMP1:%.*]] = sdiv i8 5, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> undef, i8 [[TMP1]], i32 0 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 0 @@ -382,8 +382,8 @@ define <2 x i8> @sdiv_constant_op1_not_undef_lane(i8 %x) { ; CHECK-LABEL: @sdiv_constant_op1_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = sdiv exact <2 x i8> [[INS]], +; CHECK-NEXT: [[TMP1:%.*]] = ashr exact i8 [[X:%.*]], 1 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> , i8 [[TMP1]], i32 1 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 1 @@ -393,8 +393,8 @@ define <2 x i8> @and_constant(i8 %x) { ; CHECK-LABEL: @and_constant( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = and <2 x i8> [[INS]], +; CHECK-NEXT: [[TMP1:%.*]] = and i8 [[X:%.*]], 42 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> undef, i8 [[TMP1]], i32 0 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 0 @@ -404,8 +404,8 @@ define <2 x i8> @and_constant_not_undef_lane(i8 %x) { ; CHECK-LABEL: @and_constant_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = and <2 x i8> [[INS]], +; CHECK-NEXT: [[TMP1:%.*]] = and i8 [[X:%.*]], 42 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> , i8 [[TMP1]], i32 0 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 0 @@ -415,8 +415,8 @@ define <2 x i8> @or_constant(i8 %x) { ; CHECK-LABEL: @or_constant( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = or <2 x i8> [[INS]], +; CHECK-NEXT: [[TMP1:%.*]] = or i8 [[X:%.*]], -42 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> undef, i8 [[TMP1]], i32 1 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 1 @@ -426,8 +426,8 @@ define <2 x i8> @or_constant_not_undef_lane(i8 %x) { ; CHECK-LABEL: @or_constant_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = or <2 x i8> [[INS]], +; CHECK-NEXT: [[TMP1:%.*]] = or i8 [[X:%.*]], -42 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> , i8 [[TMP1]], i32 1 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 1 @@ -437,8 +437,8 @@ define <2 x i8> @xor_constant(i8 %x) { ; CHECK-LABEL: @xor_constant( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = xor <2 x i8> [[INS]], +; CHECK-NEXT: [[TMP1:%.*]] = xor i8 [[X:%.*]], 42 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> , i8 [[TMP1]], i32 0 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 0 @@ -448,8 +448,8 @@ define <2 x i8> @xor_constant_not_undef_lane(i8 %x) { ; CHECK-LABEL: @xor_constant_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = xor <2 x i8> [[INS]], +; CHECK-NEXT: [[TMP1:%.*]] = xor i8 [[X:%.*]], 42 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i8> undef, i8 [[TMP1]], i32 0 ; CHECK-NEXT: ret <2 x i8> [[BO]] ; %ins = insertelement <2 x i8> undef, i8 %x, i32 0 @@ -459,8 +459,8 @@ define <2 x float> @fadd_constant(float %x) { ; CHECK-LABEL: @fadd_constant( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x float> undef, float [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = fadd <2 x float> [[INS]], +; CHECK-NEXT: [[TMP1:%.*]] = fadd float [[X:%.*]], 4.200000e+01 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x float> undef, float [[TMP1]], i32 0 ; CHECK-NEXT: ret <2 x float> [[BO]] ; %ins = insertelement <2 x float> undef, float %x, i32 0 @@ -470,8 +470,8 @@ define <2 x float> @fadd_constant_not_undef_lane(float %x) { ; CHECK-LABEL: @fadd_constant_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x float> undef, float [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = fadd <2 x float> [[INS]], +; CHECK-NEXT: [[TMP1:%.*]] = fadd float [[X:%.*]], -4.200000e+01 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x float> , float [[TMP1]], i32 1 ; CHECK-NEXT: ret <2 x float> [[BO]] ; %ins = insertelement <2 x float> undef, float %x, i32 1 @@ -481,8 +481,8 @@ define <2 x float> @fsub_constant_op0(float %x) { ; CHECK-LABEL: @fsub_constant_op0( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x float> undef, float [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = fsub fast <2 x float> , [[INS]] +; CHECK-NEXT: [[TMP1:%.*]] = fsub fast float 4.200000e+01, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x float> undef, float [[TMP1]], i32 0 ; CHECK-NEXT: ret <2 x float> [[BO]] ; %ins = insertelement <2 x float> undef, float %x, i32 0 @@ -492,8 +492,8 @@ define <2 x float> @fsub_constant_op0_not_undef_lane(float %x) { ; CHECK-LABEL: @fsub_constant_op0_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x float> undef, float [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = fsub nsz <2 x float> , [[INS]] +; CHECK-NEXT: [[TMP1:%.*]] = fsub nsz float -4.200000e+01, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x float> , float [[TMP1]], i32 1 ; CHECK-NEXT: ret <2 x float> [[BO]] ; %ins = insertelement <2 x float> undef, float %x, i32 1 @@ -503,8 +503,8 @@ define <2 x float> @fsub_constant_op1(float %x) { ; CHECK-LABEL: @fsub_constant_op1( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x float> undef, float [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = fadd <2 x float> [[INS]], +; CHECK-NEXT: [[TMP1:%.*]] = fadd float [[X:%.*]], -4.200000e+01 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x float> undef, float [[TMP1]], i32 1 ; CHECK-NEXT: ret <2 x float> [[BO]] ; %ins = insertelement <2 x float> undef, float %x, i32 1 @@ -514,8 +514,8 @@ define <2 x float> @fsub_constant_op1_not_undef_lane(float %x) { ; CHECK-LABEL: @fsub_constant_op1_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x float> undef, float [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = fadd <2 x float> [[INS]], +; CHECK-NEXT: [[TMP1:%.*]] = fadd float [[X:%.*]], -4.200000e+01 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x float> , float [[TMP1]], i32 0 ; CHECK-NEXT: ret <2 x float> [[BO]] ; %ins = insertelement <2 x float> undef, float %x, i32 0 @@ -525,8 +525,8 @@ define <2 x float> @fmul_constant(float %x) { ; CHECK-LABEL: @fmul_constant( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x float> undef, float [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = fmul reassoc <2 x float> [[INS]], +; CHECK-NEXT: [[TMP1:%.*]] = fmul reassoc float [[X:%.*]], 4.200000e+01 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x float> undef, float [[TMP1]], i32 0 ; CHECK-NEXT: ret <2 x float> [[BO]] ; %ins = insertelement <2 x float> undef, float %x, i32 0 @@ -536,8 +536,8 @@ define <2 x float> @fmul_constant_not_undef_lane(float %x) { ; CHECK-LABEL: @fmul_constant_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x float> undef, float [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = fmul <2 x float> [[INS]], +; CHECK-NEXT: [[TMP1:%.*]] = fmul float [[X:%.*]], -4.200000e+01 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x float> , float [[TMP1]], i32 1 ; CHECK-NEXT: ret <2 x float> [[BO]] ; %ins = insertelement <2 x float> undef, float %x, i32 1 @@ -547,8 +547,8 @@ define <2 x float> @fdiv_constant_op0(float %x) { ; CHECK-LABEL: @fdiv_constant_op0( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x float> undef, float [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = fdiv nnan <2 x float> , [[INS]] +; CHECK-NEXT: [[TMP1:%.*]] = fdiv nnan float 4.200000e+01, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x float> undef, float [[TMP1]], i32 1 ; CHECK-NEXT: ret <2 x float> [[BO]] ; %ins = insertelement <2 x float> undef, float %x, i32 1 @@ -558,8 +558,8 @@ define <2 x float> @fdiv_constant_op0_not_undef_lane(float %x) { ; CHECK-LABEL: @fdiv_constant_op0_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x float> undef, float [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = fdiv ninf <2 x float> , [[INS]] +; CHECK-NEXT: [[TMP1:%.*]] = fdiv ninf float 4.200000e+01, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x float> , float [[TMP1]], i32 0 ; CHECK-NEXT: ret <2 x float> [[BO]] ; %ins = insertelement <2 x float> undef, float %x, i32 0 @@ -569,8 +569,8 @@ define <2 x float> @fdiv_constant_op1(float %x) { ; CHECK-LABEL: @fdiv_constant_op1( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x float> undef, float [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = fdiv <2 x float> [[INS]], +; CHECK-NEXT: [[TMP1:%.*]] = fdiv float [[X:%.*]], 4.200000e+01 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x float> undef, float [[TMP1]], i32 0 ; CHECK-NEXT: ret <2 x float> [[BO]] ; %ins = insertelement <2 x float> undef, float %x, i32 0 @@ -580,8 +580,8 @@ define <2 x float> @fdiv_constant_op1_not_undef_lane(float %x) { ; CHECK-LABEL: @fdiv_constant_op1_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x float> undef, float [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = fdiv <2 x float> [[INS]], +; CHECK-NEXT: [[TMP1:%.*]] = fdiv float [[X:%.*]], 4.200000e+01 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x float> , float [[TMP1]], i32 0 ; CHECK-NEXT: ret <2 x float> [[BO]] ; %ins = insertelement <2 x float> undef, float %x, i32 0 @@ -591,8 +591,8 @@ define <2 x float> @frem_constant_op0(float %x) { ; CHECK-LABEL: @frem_constant_op0( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x float> undef, float [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = frem fast <2 x float> , [[INS]] +; CHECK-NEXT: [[TMP1:%.*]] = frem fast float 4.200000e+01, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x float> undef, float [[TMP1]], i32 0 ; CHECK-NEXT: ret <2 x float> [[BO]] ; %ins = insertelement <2 x float> undef, float %x, i32 0 @@ -602,8 +602,8 @@ define <2 x float> @frem_constant_op0_not_undef_lane(float %x) { ; CHECK-LABEL: @frem_constant_op0_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x float> undef, float [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = frem <2 x float> , [[INS]] +; CHECK-NEXT: [[TMP1:%.*]] = frem float -4.200000e+01, [[X:%.*]] +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x float> , float [[TMP1]], i32 1 ; CHECK-NEXT: ret <2 x float> [[BO]] ; %ins = insertelement <2 x float> undef, float %x, i32 1 @@ -613,8 +613,8 @@ define <2 x float> @frem_constant_op1(float %x) { ; CHECK-LABEL: @frem_constant_op1( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x float> undef, float [[X:%.*]], i32 1 -; CHECK-NEXT: [[BO:%.*]] = frem ninf <2 x float> [[INS]], +; CHECK-NEXT: [[TMP1:%.*]] = frem ninf float [[X:%.*]], 4.200000e+01 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x float> undef, float [[TMP1]], i32 1 ; CHECK-NEXT: ret <2 x float> [[BO]] ; %ins = insertelement <2 x float> undef, float %x, i32 1 @@ -624,8 +624,8 @@ define <2 x float> @frem_constant_op1_not_undef_lane(float %x) { ; CHECK-LABEL: @frem_constant_op1_not_undef_lane( -; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x float> undef, float [[X:%.*]], i32 0 -; CHECK-NEXT: [[BO:%.*]] = frem nnan <2 x float> [[INS]], +; CHECK-NEXT: [[TMP1:%.*]] = frem nnan float [[X:%.*]], 4.200000e+01 +; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x float> , float [[TMP1]], i32 0 ; CHECK-NEXT: ret <2 x float> [[BO]] ; %ins = insertelement <2 x float> undef, float %x, i32 0