Index: lib/Target/SystemZ/SystemZISelLowering.h =================================================================== --- lib/Target/SystemZ/SystemZISelLowering.h +++ lib/Target/SystemZ/SystemZISelLowering.h @@ -605,6 +605,7 @@ SDValue combineBR_CCMASK(SDNode *N, DAGCombinerInfo &DCI) const; SDValue combineSELECT_CCMASK(SDNode *N, DAGCombinerInfo &DCI) const; SDValue combineGET_CCMASK(SDNode *N, DAGCombinerInfo &DCI) const; + SDValue combineIntDIVREM(SDNode *N, DAGCombinerInfo &DCI) const; // If the last instruction before MBBI in MBB was some form of COMPARE, // try to replace it with a COMPARE AND BRANCH just before MBBI. Index: lib/Target/SystemZ/SystemZISelLowering.cpp =================================================================== --- lib/Target/SystemZ/SystemZISelLowering.cpp +++ lib/Target/SystemZ/SystemZISelLowering.cpp @@ -527,6 +527,10 @@ setTargetDAGCombine(ISD::EXTRACT_VECTOR_ELT); setTargetDAGCombine(ISD::FP_ROUND); setTargetDAGCombine(ISD::BSWAP); + setTargetDAGCombine(ISD::SDIV); + setTargetDAGCombine(ISD::UDIV); + setTargetDAGCombine(ISD::SREM); + setTargetDAGCombine(ISD::UREM); // Handle intrinsics. setOperationAction(ISD::INTRINSIC_W_CHAIN, MVT::Other, Custom); @@ -5664,6 +5668,23 @@ return Select->getOperand(4); } +SDValue SystemZTargetLowering::combineIntDIVREM( + SDNode *N, DAGCombinerInfo &DCI) const { + SelectionDAG &DAG = DCI.DAG; + EVT VT = N->getValueType(0); + // In the case where the divisor is a vector of constants a cheaper + // sequence of instructions can replace the divide. BuildSDIV is called to + // do this during DAG combining, but it only succeeds when it can build a + // multiplication node. The only option for SystemZ is ISD::SMUL_LOHI, and + // since it is not Legal but Custom it can only happen before + // legalization. Therefore we must scalarize this early before Combine + // 1. For widened vectors, this is already the result of type legalization. + if (VT.isVector() && isTypeLegal(VT) && + DAG.isConstantIntBuildVectorOrConstantInt(N->getOperand(1))) + return DAG.UnrollVectorOp(N); + return SDValue(); +} + SDValue SystemZTargetLowering::PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const { switch(N->getOpcode()) { @@ -5681,6 +5702,10 @@ case SystemZISD::BR_CCMASK: return combineBR_CCMASK(N, DCI); case SystemZISD::SELECT_CCMASK: return combineSELECT_CCMASK(N, DCI); case SystemZISD::GET_CCMASK: return combineGET_CCMASK(N, DCI); + case ISD::SDIV: + case ISD::UDIV: + case ISD::SREM: + case ISD::UREM: return combineIntDIVREM(N, DCI); } return SDValue(); Index: lib/Target/SystemZ/SystemZTargetTransformInfo.cpp =================================================================== --- lib/Target/SystemZ/SystemZTargetTransformInfo.cpp +++ lib/Target/SystemZ/SystemZTargetTransformInfo.cpp @@ -362,27 +362,33 @@ unsigned ScalarBits = Ty->getScalarSizeInBits(); - // Div with a constant which is a power of 2 will be converted by - // DAGCombiner to use shifts. With vector shift-element instructions, a - // vector sdiv costs about as much as a scalar one. - const unsigned SDivCostEstimate = 4; - bool SDivPow2 = false; - bool UDivPow2 = false; - if ((Opcode == Instruction::SDiv || Opcode == Instruction::UDiv) && - Args.size() == 2) { - const ConstantInt *CI = nullptr; + // There are thre cases of division and remainder: Dividing with a register + // needs a divide instruction. A divisor which is a power of two constant + // can be implemented with a sequence of shifts. Any other constant needs a + // multiply and shifts. + const unsigned DivInstrCost = 20; + const unsigned DivMulSeqCost = 10; + const unsigned SDivPow2Cost = 4; + + bool SignedDivRem = + Opcode == Instruction::SDiv || Opcode == Instruction::SRem; + bool UnsignedDivRem = + Opcode == Instruction::UDiv || Opcode == Instruction::URem; + + // Check for a constant divisor. + bool DivRemConst = false; + bool DivRemConstPow2 = false; + if ((SignedDivRem || UnsignedDivRem) && Args.size() == 2) { if (const Constant *C = dyn_cast(Args[1])) { - if (C->getType()->isVectorTy()) - CI = dyn_cast_or_null(C->getSplatValue()); + const ConstantInt *CVal = + (C->getType()->isVectorTy() + ? dyn_cast_or_null(C->getSplatValue()) + : dyn_cast(C)); + if (CVal != nullptr && + (CVal->getValue().isPowerOf2() || (-CVal->getValue()).isPowerOf2())) + DivRemConstPow2 = true; else - CI = dyn_cast(C); - } - if (CI != nullptr && - (CI->getValue().isPowerOf2() || (-CI->getValue()).isPowerOf2())) { - if (Opcode == Instruction::SDiv) - SDivPow2 = true; - else - UDivPow2 = true; + DivRemConst = true; } } @@ -394,18 +400,19 @@ // These vector operations are custom handled, but are still supported // with one instruction per vector, regardless of element size. if (Opcode == Instruction::Shl || Opcode == Instruction::LShr || - Opcode == Instruction::AShr || UDivPow2) { + Opcode == Instruction::AShr) { return NumVectors; } - if (SDivPow2) - return (NumVectors * SDivCostEstimate); - - // Temporary hack: disable high vectorization factors with integer - // division/remainder, which will get scalarized and handled with GR128 - // registers. The mischeduler is not clever enough to avoid spilling yet. - if ((Opcode == Instruction::UDiv || Opcode == Instruction::SDiv || - Opcode == Instruction::URem || Opcode == Instruction::SRem) && VF > 4) + if (DivRemConstPow2) + return (NumVectors * (SignedDivRem ? SDivPow2Cost : 1)); + if (DivRemConst) + return VF * DivMulSeqCost + getScalarizationOverhead(Ty, Args); + if ((SignedDivRem || UnsignedDivRem) && VF > 4) + // Temporary hack: disable high vectorization factors with integer + // division/remainder, which will get scalarized and handled with + // GR128 registers. The mischeduler is not clever enough to avoid + // spilling yet. return 1000; // These FP operations are supported with a single vector instruction for @@ -471,19 +478,16 @@ return 7; // 2 * ipm sequences ; xor ; shift ; compare } - if (UDivPow2) - return 1; - if (SDivPow2) - return SDivCostEstimate; - - // An extra extension for narrow types is needed. - if ((Opcode == Instruction::SDiv || Opcode == Instruction::SRem)) + if (DivRemConstPow2) + return (SignedDivRem ? SDivPow2Cost : 1); + if (DivRemConst) + return DivMulSeqCost; + if (SignedDivRem) // sext of op(s) for narrow types - return (ScalarBits < 32 ? 4 : (ScalarBits == 32 ? 2 : 1)); - - if (Opcode == Instruction::UDiv || Opcode == Instruction::URem) + return DivInstrCost + (ScalarBits < 32 ? 3 : (ScalarBits == 32 ? 1 : 0)); + if (UnsignedDivRem) // Clearing of low 64 bit reg + sext of op(s) for narrow types + dl[g]r - return (ScalarBits < 32 ? 4 : 2); + return DivInstrCost + (ScalarBits < 32 ? 3 : 1); } // Fallback to the default implementation. Index: test/Analysis/CostModel/SystemZ/div-pow2.ll =================================================================== --- test/Analysis/CostModel/SystemZ/div-pow2.ll +++ /dev/null @@ -1,154 +0,0 @@ -; RUN: opt < %s -cost-model -analyze -mtriple=systemz-unknown -mcpu=z13 | FileCheck %s - -; Scalar sdiv - -define i64 @fun0(i64 %a) { - %r = sdiv i64 %a, 2 - ret i64 %r -; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv i64 %a, 2 -} - -define i64 @fun1(i64 %a) { - %r = sdiv i64 %a, -4 - ret i64 %r -; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv i64 %a, -4 -} - -define i32 @fun2(i32 %a) { - %r = sdiv i32 %a, 8 - ret i32 %r -; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv i32 %a, 8 -} - -define i32 @fun3(i32 %a) { - %r = sdiv i32 %a, -16 - ret i32 %r -; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv i32 %a, -16 -} - -define i16 @fun4(i16 %a) { - %r = sdiv i16 %a, 32 - ret i16 %r -; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv i16 %a, 32 -} - -define i16 @fun5(i16 %a) { - %r = sdiv i16 %a, -64 - ret i16 %r -; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv i16 %a, -64 -} - -define i8 @fun6(i8 %a) { - %r = sdiv i8 %a, 64 - ret i8 %r -; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv i8 %a, 64 -} - -define i8 @fun7(i8 %a) { - %r = sdiv i8 %a, -128 - ret i8 %r -; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv i8 %a, -128 -} - - -; Vector sdiv - -define <2 x i64> @fun8(<2 x i64> %a) { - %r = sdiv <2 x i64> %a, - ret <2 x i64> %r -; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <2 x i64> %a, -} - -define <2 x i64> @fun9(<2 x i64> %a) { - %r = sdiv <2 x i64> %a, - ret <2 x i64> %r -; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <2 x i64> %a, -} - -define <4 x i32> @fun10(<4 x i32> %a) { - %r = sdiv <4 x i32> %a, - ret <4 x i32> %r -; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <4 x i32> %a, -} - -define <4 x i32> @fun11(<4 x i32> %a) { - %r = sdiv <4 x i32> %a, - ret <4 x i32> %r -; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <4 x i32> %a, @fun12(<8 x i16> %a) { - %r = sdiv <8 x i16> %a, - ret <8 x i16> %r -; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <8 x i16> %a, @fun13(<8 x i16> %a) { - %r = sdiv <8 x i16> %a, - ret <8 x i16> %r -; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <8 x i16> %a, @fun14(<16 x i8> %a) { - %r = sdiv <16 x i8> %a, - ret <16 x i8> %r -; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <16 x i8> %a, @fun15(<16 x i8> %a) { - %r = sdiv <16 x i8> %a, - ret <16 x i8> %r -; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <16 x i8> %a, @fun20(<2 x i64> %a) { - %r = udiv <2 x i64> %a, - ret <2 x i64> %r -; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %r = udiv <2 x i64> %a, @fun21(<4 x i32> %a) { - %r = udiv <4 x i32> %a, - ret <4 x i32> %r -; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %r = udiv <4 x i32> %a, @fun22(<8 x i16> %a) { - %r = udiv <8 x i16> %a, - ret <8 x i16> %r -; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %r = udiv <8 x i16> %a, @fun23(<16 x i8> %a) { - %r = udiv <16 x i8> %a, - ret <16 x i8> %r -; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %r = udiv <16 x i8> %a, @fun4(<2 x i64> %a) { + %r = sdiv <2 x i64> %a, + ret <2 x i64> %r +; COST: Cost Model: Found an estimated cost of 24 for instruction: %r = sdiv <2 x i64> +} + +define <4 x i32> @fun5(<4 x i32> %a) { + %r = sdiv <4 x i32> %a, + ret <4 x i32> %r +; COST: Cost Model: Found an estimated cost of 49 for instruction: %r = sdiv <4 x i32> +} + +define <2 x i32> @fun6(<2 x i32> %a) { + %r = sdiv <2 x i32> %a, + ret <2 x i32> %r +; COST: Cost Model: Found an estimated cost of 25 for instruction: %r = sdiv <2 x i32> +} + +define <8 x i16> @fun7(<8 x i16> %a) { + %r = sdiv <8 x i16> %a, + ret <8 x i16> %r +; COST: Cost Model: Found an estimated cost of 97 for instruction: %r = sdiv <8 x i16> +} + +define <4 x i16> @fun8(<4 x i16> %a) { + %r = sdiv <4 x i16> %a, + ret <4 x i16> %r +; COST: Cost Model: Found an estimated cost of 49 for instruction: %r = sdiv <4 x i16> +} + +define <16 x i8> @fun9(<16 x i8> %a) { + %r = sdiv <16 x i8> %a, + ret <16 x i8> %r +; COST: Cost Model: Found an estimated cost of 193 for instruction: %r = sdiv <16 x i8> +} + +define <8 x i8> @fun10(<8 x i8> %a) { + %r = sdiv <8 x i8> %a, + ret <8 x i8> %r +; COST: Cost Model: Found an estimated cost of 97 for instruction: %r = sdiv <8 x i8> +} + +; Scalar udiv + +define i64 @fun11(i64 %a) { + %r = udiv i64 %a, 20 + ret i64 %r +; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = udiv i64 %a, 20 +} + +define i32 @fun12(i32 %a) { + %r = udiv i32 %a, 20 + ret i32 %r +; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = udiv i32 %a, 20 +} + +define i16 @fun13(i16 %a) { + %r = udiv i16 %a, 20 + ret i16 %r +; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = udiv i16 %a, 20 +} + +define i8 @fun14(i8 %a) { + %r = udiv i8 %a, 20 + ret i8 %r +; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = udiv i8 +} + +; Vector udiv + +define <2 x i64> @fun15(<2 x i64> %a) { + %r = udiv <2 x i64> %a, + ret <2 x i64> %r +; COST: Cost Model: Found an estimated cost of 24 for instruction: %r = udiv <2 x i64> +} + +define <4 x i32> @fun16(<4 x i32> %a) { + %r = udiv <4 x i32> %a, + ret <4 x i32> %r +; COST: Cost Model: Found an estimated cost of 49 for instruction: %r = udiv <4 x i32> +} + +define <2 x i32> @fun17(<2 x i32> %a) { + %r = udiv <2 x i32> %a, + ret <2 x i32> %r +; COST: Cost Model: Found an estimated cost of 25 for instruction: %r = udiv <2 x i32> +} + +define <8 x i16> @fun18(<8 x i16> %a) { + %r = udiv <8 x i16> %a, + ret <8 x i16> %r +; COST: Cost Model: Found an estimated cost of 97 for instruction: %r = udiv <8 x i16> +} + +define <4 x i16> @fun19(<4 x i16> %a) { + %r = udiv <4 x i16> %a, + ret <4 x i16> %r +; COST: Cost Model: Found an estimated cost of 49 for instruction: %r = udiv <4 x i16> +} + +define <16 x i8> @fun20(<16 x i8> %a) { + %r = udiv <16 x i8> %a, + ret <16 x i8> %r +; COST: Cost Model: Found an estimated cost of 193 for instruction: %r = udiv <16 x i8> +} + +define <8 x i8> @fun21(<8 x i8> %a) { + %r = udiv <8 x i8> %a, + ret <8 x i8> %r +; COST: Cost Model: Found an estimated cost of 97 for instruction: %r = udiv <8 x i8> +} + +; Scalar srem + +define i64 @fun22(i64 %a) { + %r = srem i64 %a, 20 + ret i64 %r +; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = srem i64 +} + +define i32 @fun23(i32 %a) { + %r = srem i32 %a, 20 + ret i32 %r +; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = srem i32 +} + +define i16 @fun24(i16 %a) { + %r = srem i16 %a, 20 + ret i16 %r +; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = srem i16 +} + +define i8 @fun25(i8 %a) { + %r = srem i8 %a, 20 + ret i8 %r +; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = srem i8 +} + +; Vector srem + +define <2 x i64> @fun26(<2 x i64> %a) { + %r = srem <2 x i64> %a, + ret <2 x i64> %r +; COST: Cost Model: Found an estimated cost of 24 for instruction: %r = srem <2 x i64> +} + +define <4 x i32> @fun27(<4 x i32> %a) { + %r = srem <4 x i32> %a, + ret <4 x i32> %r +; COST: Cost Model: Found an estimated cost of 49 for instruction: %r = srem <4 x i32> +} + +define <2 x i32> @fun28(<2 x i32> %a) { + %r = srem <2 x i32> %a, + ret <2 x i32> %r +; COST: Cost Model: Found an estimated cost of 25 for instruction: %r = srem <2 x i32> +} + +define <8 x i16> @fun29(<8 x i16> %a) { + %r = srem <8 x i16> %a, + ret <8 x i16> %r +; COST: Cost Model: Found an estimated cost of 97 for instruction: %r = srem <8 x i16> +} + +define <4 x i16> @fun30(<4 x i16> %a) { + %r = srem <4 x i16> %a, + ret <4 x i16> %r +; COST: Cost Model: Found an estimated cost of 49 for instruction: %r = srem <4 x i16> +} + +define <16 x i8> @fun31(<16 x i8> %a) { + %r = srem <16 x i8> %a, + ret <16 x i8> %r +; COST: Cost Model: Found an estimated cost of 193 for instruction: %r = srem <16 x i8> +} + +define <8 x i8> @fun32(<8 x i8> %a) { + %r = srem <8 x i8> %a, + ret <8 x i8> %r +; COST: Cost Model: Found an estimated cost of 97 for instruction: %r = srem <8 x i8> +} + +; Scalar urem + +define i64 @fun33(i64 %a) { + %r = urem i64 %a, 20 + ret i64 %r +; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = urem i64 +} + +define i32 @fun34(i32 %a) { + %r = urem i32 %a, 20 + ret i32 %r +; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = urem i32 +} + +define i16 @fun35(i16 %a) { + %r = urem i16 %a, 20 + ret i16 %r +; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = urem i16 +} + +define i8 @fun36(i8 %a) { + %r = urem i8 %a, 20 + ret i8 %r +; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = urem i8 +} + +; Vector urem + +define <2 x i64> @fun37(<2 x i64> %a) { + %r = urem <2 x i64> %a, + ret <2 x i64> %r +; COST: Cost Model: Found an estimated cost of 24 for instruction: %r = urem <2 x i64> +} + +define <4 x i32> @fun38(<4 x i32> %a) { + %r = urem <4 x i32> %a, + ret <4 x i32> %r +; COST: Cost Model: Found an estimated cost of 49 for instruction: %r = urem <4 x i32> +} + +define <2 x i32> @fun39(<2 x i32> %a) { + %r = urem <2 x i32> %a, + ret <2 x i32> %r +; COST: Cost Model: Found an estimated cost of 25 for instruction: %r = urem <2 x i32> +} + +define <8 x i16> @fun40(<8 x i16> %a) { + %r = urem <8 x i16> %a, + ret <8 x i16> %r +; COST: Cost Model: Found an estimated cost of 97 for instruction: %r = urem <8 x i16> +} + +define <4 x i16> @fun41(<4 x i16> %a) { + %r = urem <4 x i16> %a, + ret <4 x i16> %r +; COST: Cost Model: Found an estimated cost of 49 for instruction: %r = urem <4 x i16> +} + +define <16 x i8> @fun42(<16 x i8> %a) { + %r = urem <16 x i8> %a, + ret <16 x i8> %r +; COST: Cost Model: Found an estimated cost of 193 for instruction: %r = urem <16 x i8> +} + +define <8 x i8> @fun43(<8 x i8> %a) { + %r = urem <8 x i8> %a, + ret <8 x i8> %r +; COST: Cost Model: Found an estimated cost of 97 for instruction: %r = urem <8 x i8> +} Index: test/Analysis/CostModel/SystemZ/divrem-pow2.ll =================================================================== --- /dev/null +++ test/Analysis/CostModel/SystemZ/divrem-pow2.ll @@ -0,0 +1,383 @@ +; RUN: opt < %s -cost-model -analyze -mtriple=systemz-unknown -mcpu=z13 \ +; RUN: | FileCheck %s -check-prefix=COST + +; Check that all divide/remainder instructions are implemented by cheaper instructions. +; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 -o - | FileCheck %s +; CHECK-NOT: dsg +; CHECK-NOT: dl + +; Scalar sdiv + +define i64 @fun0(i64 %a) { + %r = sdiv i64 %a, 2 + ret i64 %r +; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv i64 %a, 2 +} + +define i64 @fun1(i64 %a) { + %r = sdiv i64 %a, -4 + ret i64 %r +; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv i64 %a, -4 +} + +define i32 @fun2(i32 %a) { + %r = sdiv i32 %a, 8 + ret i32 %r +; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv i32 %a, 8 +} + +define i32 @fun3(i32 %a) { + %r = sdiv i32 %a, -16 + ret i32 %r +; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv i32 %a, -16 +} + +define i16 @fun4(i16 %a) { + %r = sdiv i16 %a, 32 + ret i16 %r +; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv i16 %a, 32 +} + +define i16 @fun5(i16 %a) { + %r = sdiv i16 %a, -64 + ret i16 %r +; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv i16 %a, -64 +} + +define i8 @fun6(i8 %a) { + %r = sdiv i8 %a, 64 + ret i8 %r +; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv i8 %a, 64 +} + +define i8 @fun7(i8 %a) { + %r = sdiv i8 %a, -128 + ret i8 %r +; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv i8 %a, -128 +} + +; Vector sdiv + +define <2 x i64> @fun8(<2 x i64> %a) { + %r = sdiv <2 x i64> %a, + ret <2 x i64> %r +; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <2 x i64> %a, +} + +define <2 x i64> @fun9(<2 x i64> %a) { + %r = sdiv <2 x i64> %a, + ret <2 x i64> %r +; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <2 x i64> %a, +} + +define <4 x i32> @fun10(<4 x i32> %a) { + %r = sdiv <4 x i32> %a, + ret <4 x i32> %r +; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <4 x i32> %a, +} + +define <4 x i32> @fun11(<4 x i32> %a) { + %r = sdiv <4 x i32> %a, + ret <4 x i32> %r +; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <4 x i32> %a, @fun12(<2 x i32> %a) { + %r = sdiv <2 x i32> %a, + ret <2 x i32> %r +; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <2 x i32> %a, @fun13(<8 x i16> %a) { + %r = sdiv <8 x i16> %a, + ret <8 x i16> %r +; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <8 x i16> %a, @fun14(<8 x i16> %a) { + %r = sdiv <8 x i16> %a, + ret <8 x i16> %r +; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <8 x i16> %a, @fun15(<4 x i16> %a) { + %r = sdiv <4 x i16> %a, + ret <4 x i16> %r +; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <4 x i16> %a, @fun16(<16 x i8> %a) { + %r = sdiv <16 x i8> %a, + ret <16 x i8> %r +; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <16 x i8> %a, @fun17(<16 x i8> %a) { + %r = sdiv <16 x i8> %a, + ret <16 x i8> %r +; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <16 x i8> %a, @fun18(<8 x i8> %a) { + %r = sdiv <8 x i8> %a, + ret <8 x i8> %r +; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <8 x i8> %a, @fun23(<2 x i64> %a) { + %r = udiv <2 x i64> %a, + ret <2 x i64> %r +; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = udiv <2 x i64> %a, @fun24(<4 x i32> %a) { + %r = udiv <4 x i32> %a, + ret <4 x i32> %r +; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = udiv <4 x i32> %a, @fun25(<2 x i32> %a) { + %r = udiv <2 x i32> %a, + ret <2 x i32> %r +; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = udiv <2 x i32> %a, @fun26(<8 x i16> %a) { + %r = udiv <8 x i16> %a, + ret <8 x i16> %r +; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = udiv <8 x i16> %a, @fun27(<4 x i16> %a) { + %r = udiv <4 x i16> %a, + ret <4 x i16> %r +; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = udiv <4 x i16> %a, @fun28(<16 x i8> %a) { + %r = udiv <16 x i8> %a, + ret <16 x i8> %r +; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = udiv <16 x i8> %a, @fun29(<8 x i8> %a) { + %r = udiv <8 x i8> %a, + ret <8 x i8> %r +; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = udiv <8 x i8> %a, @fun38(<2 x i64> %a) { + %r = srem <2 x i64> %a, + ret <2 x i64> %r +; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = srem <2 x i64> %a, +} + +define <2 x i64> @fun39(<2 x i64> %a) { + %r = srem <2 x i64> %a, + ret <2 x i64> %r +; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = srem <2 x i64> %a, +} + +define <4 x i32> @fun40(<4 x i32> %a) { + %r = srem <4 x i32> %a, + ret <4 x i32> %r +; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = srem <4 x i32> %a, +} + +define <4 x i32> @fun41(<4 x i32> %a) { + %r = srem <4 x i32> %a, + ret <4 x i32> %r +; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = srem <4 x i32> %a, @fun42(<2 x i32> %a) { + %r = srem <2 x i32> %a, + ret <2 x i32> %r +; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = srem <2 x i32> %a, @fun43(<8 x i16> %a) { + %r = srem <8 x i16> %a, + ret <8 x i16> %r +; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = srem <8 x i16> %a, @fun44(<8 x i16> %a) { + %r = srem <8 x i16> %a, + ret <8 x i16> %r +; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = srem <8 x i16> %a, @fun45(<4 x i16> %a) { + %r = srem <4 x i16> %a, + ret <4 x i16> %r +; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = srem <4 x i16> %a, @fun46(<16 x i8> %a) { + %r = srem <16 x i8> %a, + ret <16 x i8> %r +; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = srem <16 x i8> %a, @fun47(<16 x i8> %a) { + %r = srem <16 x i8> %a, + ret <16 x i8> %r +; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = srem <16 x i8> %a, @fun48(<8 x i8> %a) { + %r = srem <8 x i8> %a, + ret <8 x i8> %r +; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = srem <8 x i8> %a, @fun53(<2 x i64> %a) { + %r = urem <2 x i64> %a, + ret <2 x i64> %r +; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = urem <2 x i64> %a, @fun54(<4 x i32> %a) { + %r = urem <4 x i32> %a, + ret <4 x i32> %r +; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = urem <4 x i32> %a, @fun55(<2 x i32> %a) { + %r = urem <2 x i32> %a, + ret <2 x i32> %r +; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = urem <2 x i32> %a, @fun56(<8 x i16> %a) { + %r = urem <8 x i16> %a, + ret <8 x i16> %r +; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = urem <8 x i16> %a, @fun57(<4 x i16> %a) { + %r = urem <4 x i16> %a, + ret <4 x i16> %r +; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = urem <4 x i16> %a, @fun58(<16 x i8> %a) { + %r = urem <16 x i8> %a, + ret <16 x i8> %r +; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = urem <16 x i8> %a, @fun59(<8 x i8> %a) { + %r = urem <8 x i8> %a, + ret <8 x i8> %r +; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = urem <8 x i8> %a, @fun4(<2 x i64> %a, <2 x i64> %b) { + %r = sdiv <2 x i64> %a, %b + ret <2 x i64> %r +; CHECK: Cost Model: Found an estimated cost of 47 for instruction: %r = sdiv <2 x i64> +} + +define <4 x i32> @fun5(<4 x i32> %a, <4 x i32> %b) { + %r = sdiv <4 x i32> %a, %b + ret <4 x i32> %r +; CHECK: Cost Model: Found an estimated cost of 98 for instruction: %r = sdiv <4 x i32> +} + +define <2 x i32> @fun6(<2 x i32> %a, <2 x i32> %b) { + %r = sdiv <2 x i32> %a, %b + ret <2 x i32> %r +; CHECK: Cost Model: Found an estimated cost of 50 for instruction: %r = sdiv <2 x i32> +} + +define <8 x i16> @fun7(<8 x i16> %a, <8 x i16> %b) { + %r = sdiv <8 x i16> %a, %b + ret <8 x i16> %r +; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %r = sdiv <8 x i16> +} + +define <4 x i16> @fun8(<4 x i16> %a, <4 x i16> %b) { + %r = sdiv <4 x i16> %a, %b + ret <4 x i16> %r +; CHECK: Cost Model: Found an estimated cost of 106 for instruction: %r = sdiv <4 x i16> +} + +define <16 x i8> @fun9(<16 x i8> %a, <16 x i8> %b) { + %r = sdiv <16 x i8> %a, %b + ret <16 x i8> %r +; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %r = sdiv <16 x i8> +} + +define <8 x i8> @fun10(<8 x i8> %a, <8 x i8> %b) { + %r = sdiv <8 x i8> %a, %b + ret <8 x i8> %r +; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %r = sdiv <8 x i8> +} + +; Scalar udiv + +define i64 @fun11(i64 %a, i64 %b) { + %r = udiv i64 %a, %b + ret i64 %r +; CHECK: Cost Model: Found an estimated cost of 21 for instruction: %r = udiv i64 %a, %b +} + +define i32 @fun12(i32 %a, i32 %b) { + %r = udiv i32 %a, %b + ret i32 %r +; CHECK: Cost Model: Found an estimated cost of 21 for instruction: %r = udiv i32 +} + +define i16 @fun13(i16 %a, i16 %b) { + %r = udiv i16 %a, %b + ret i16 %r +; CHECK: Cost Model: Found an estimated cost of 23 for instruction: %r = udiv i16 +} + +define i8 @fun14(i8 %a, i8 %b) { + %r = udiv i8 %a, %b + ret i8 %r +; CHECK: Cost Model: Found an estimated cost of 23 for instruction: %r = udiv i8 +} + +; Vector udiv + +define <2 x i64> @fun15(<2 x i64> %a, <2 x i64> %b) { + %r = udiv <2 x i64> %a, %b + ret <2 x i64> %r +; CHECK: Cost Model: Found an estimated cost of 49 for instruction: %r = udiv <2 x i64> +} + +define <4 x i32> @fun16(<4 x i32> %a, <4 x i32> %b) { + %r = udiv <4 x i32> %a, %b + ret <4 x i32> %r +; CHECK: Cost Model: Found an estimated cost of 98 for instruction: %r = udiv <4 x i32> +} + +define <2 x i32> @fun17(<2 x i32> %a, <2 x i32> %b) { + %r = udiv <2 x i32> %a, %b + ret <2 x i32> %r +; CHECK: Cost Model: Found an estimated cost of 50 for instruction: %r = udiv <2 x i32> +} + +define <8 x i16> @fun18(<8 x i16> %a, <8 x i16> %b) { + %r = udiv <8 x i16> %a, %b + ret <8 x i16> %r +; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %r = udiv <8 x i16> +} + +define <4 x i16> @fun19(<4 x i16> %a, <4 x i16> %b) { + %r = udiv <4 x i16> %a, %b + ret <4 x i16> %r +; CHECK: Cost Model: Found an estimated cost of 106 for instruction: %r = udiv <4 x i16> +} + +define <16 x i8> @fun20(<16 x i8> %a, <16 x i8> %b) { + %r = udiv <16 x i8> %a, %b + ret <16 x i8> %r +; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %r = udiv <16 x i8> +} + +define <8 x i8> @fun21(<8 x i8> %a, <8 x i8> %b) { + %r = udiv <8 x i8> %a, %b + ret <8 x i8> %r +; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %r = udiv <8 x i8> +} + +; Scalar srem + +define i64 @fun22(i64 %a, i64 %b) { + %r = srem i64 %a, %b + ret i64 %r +; CHECK: Cost Model: Found an estimated cost of 20 for instruction: %r = srem i64 +} + +define i32 @fun23(i32 %a, i32 %b) { + %r = srem i32 %a, %b + ret i32 %r +; CHECK: Cost Model: Found an estimated cost of 21 for instruction: %r = srem i32 +} + +define i16 @fun24(i16 %a, i16 %b) { + %r = srem i16 %a, %b + ret i16 %r +; CHECK: Cost Model: Found an estimated cost of 23 for instruction: %r = srem i16 +} + +define i8 @fun25(i8 %a, i8 %b) { + %r = srem i8 %a, %b + ret i8 %r +; CHECK: Cost Model: Found an estimated cost of 23 for instruction: %r = srem i8 +} + +; Vector srem + +define <2 x i64> @fun26(<2 x i64> %a, <2 x i64> %b) { + %r = srem <2 x i64> %a, %b + ret <2 x i64> %r +; CHECK: Cost Model: Found an estimated cost of 47 for instruction: %r = srem <2 x i64> +} + +define <4 x i32> @fun27(<4 x i32> %a, <4 x i32> %b) { + %r = srem <4 x i32> %a, %b + ret <4 x i32> %r +; CHECK: Cost Model: Found an estimated cost of 98 for instruction: %r = srem <4 x i32> +} + +define <2 x i32> @fun28(<2 x i32> %a, <2 x i32> %b) { + %r = srem <2 x i32> %a, %b + ret <2 x i32> %r +; CHECK: Cost Model: Found an estimated cost of 50 for instruction: %r = srem <2 x i32> +} + +define <8 x i16> @fun29(<8 x i16> %a, <8 x i16> %b) { + %r = srem <8 x i16> %a, %b + ret <8 x i16> %r +; CHECK: ost Model: Found an estimated cost of 1000 for instruction: %r = srem <8 x i16> +} + +define <4 x i16> @fun30(<4 x i16> %a, <4 x i16> %b) { + %r = srem <4 x i16> %a, %b + ret <4 x i16> %r +; CHECK: Cost Model: Found an estimated cost of 106 for instruction: %r = srem <4 x i16> +} + +define <16 x i8> @fun31(<16 x i8> %a, <16 x i8> %b) { + %r = srem <16 x i8> %a, %b + ret <16 x i8> %r +; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %r = srem <16 x i8> +} + +define <8 x i8> @fun32(<8 x i8> %a, <8 x i8> %b) { + %r = srem <8 x i8> %a, %b + ret <8 x i8> %r +; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %r = srem <8 x i8> +} + +; Scalar urem + +define i64 @fun33(i64 %a, i64 %b) { + %r = urem i64 %a, %b + ret i64 %r +; CHECK: Cost Model: Found an estimated cost of 21 for instruction: %r = urem i64 +} + +define i32 @fun34(i32 %a, i32 %b) { + %r = urem i32 %a, %b + ret i32 %r +; CHECK: Cost Model: Found an estimated cost of 21 for instruction: %r = urem i32 +} + +define i16 @fun35(i16 %a, i16 %b) { + %r = urem i16 %a, %b + ret i16 %r +; CHECK: Cost Model: Found an estimated cost of 23 for instruction: %r = urem i16 +} + +define i8 @fun36(i8 %a, i8 %b) { + %r = urem i8 %a, %b + ret i8 %r +; CHECK: Cost Model: Found an estimated cost of 23 for instruction: %r = urem i8 +} + +; Vector urem + +define <2 x i64> @fun37(<2 x i64> %a, <2 x i64> %b) { + %r = urem <2 x i64> %a, %b + ret <2 x i64> %r +; CHECK: Cost Model: Found an estimated cost of 49 for instruction: %r = urem <2 x i64> +} + +define <4 x i32> @fun38(<4 x i32> %a, <4 x i32> %b) { + %r = urem <4 x i32> %a, %b + ret <4 x i32> %r +; CHECK: Cost Model: Found an estimated cost of 98 for instruction: %r = urem <4 x i32> +} + +define <2 x i32> @fun39(<2 x i32> %a, <2 x i32> %b) { + %r = urem <2 x i32> %a, %b + ret <2 x i32> %r +; CHECK: Cost Model: Found an estimated cost of 50 for instruction: %r = urem <2 x i32> +} + +define <8 x i16> @fun40(<8 x i16> %a, <8 x i16> %b) { + %r = urem <8 x i16> %a, %b + ret <8 x i16> %r +; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %r = urem <8 x i16> +} + +define <4 x i16> @fun41(<4 x i16> %a, <4 x i16> %b) { + %r = urem <4 x i16> %a, %b + ret <4 x i16> %r +; CHECK: Cost Model: Found an estimated cost of 106 for instruction: %r = urem <4 x i16> +} + +define <16 x i8> @fun42(<16 x i8> %a, <16 x i8> %b) { + %r = urem <16 x i8> %a, %b + ret <16 x i8> %r +; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %r = urem <16 x i8> +} + +define <8 x i8> @fun43(<8 x i8> %a, <8 x i8> %b) { + %r = urem <8 x i8> %a, %b + ret <8 x i8> %r +; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %r = urem <8 x i8> +} Index: test/Analysis/CostModel/SystemZ/int-arith.ll =================================================================== --- test/Analysis/CostModel/SystemZ/int-arith.ll +++ test/Analysis/CostModel/SystemZ/int-arith.ll @@ -2,9 +2,6 @@ ; ; Note: The scalarized vector instructions costs are not including any ; extracts, due to the undef operands. -; -; Note: Vectorization of division/remainder is temporarily disabled for high -; vectorization factors by returning 1000. define void @add() { %res0 = add i8 undef, undef @@ -143,187 +140,3 @@ ret void; } - -define void @sdiv() { - %res0 = sdiv i8 undef, undef - %res1 = sdiv i16 undef, undef - %res2 = sdiv i32 undef, undef - %res3 = sdiv i64 undef, undef - %res4 = sdiv <2 x i8> undef, undef - %res5 = sdiv <2 x i16> undef, undef - %res6 = sdiv <2 x i32> undef, undef - %res7 = sdiv <2 x i64> undef, undef - %res8 = sdiv <4 x i8> undef, undef - %res9 = sdiv <4 x i16> undef, undef - %res10 = sdiv <4 x i32> undef, undef - %res11 = sdiv <4 x i64> undef, undef - %res12 = sdiv <8 x i8> undef, undef - %res13 = sdiv <8 x i16> undef, undef - %res14 = sdiv <8 x i32> undef, undef - %res15 = sdiv <8 x i64> undef, undef - %res16 = sdiv <16 x i8> undef, undef - %res17 = sdiv <16 x i16> undef, undef - %res18 = sdiv <16 x i32> undef, undef - %res19 = sdiv <16 x i64> undef, undef - -; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %res0 = sdiv i8 undef, undef -; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %res1 = sdiv i16 undef, undef -; CHECK: Cost Model: Found an estimated cost of 2 for instruction: %res2 = sdiv i32 undef, undef -; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %res3 = sdiv i64 undef, undef -; CHECK: Cost Model: Found an estimated cost of 10 for instruction: %res4 = sdiv <2 x i8> undef, undef -; CHECK: Cost Model: Found an estimated cost of 10 for instruction: %res5 = sdiv <2 x i16> undef, undef -; CHECK: Cost Model: Found an estimated cost of 6 for instruction: %res6 = sdiv <2 x i32> undef, undef -; CHECK: Cost Model: Found an estimated cost of 3 for instruction: %res7 = sdiv <2 x i64> undef, undef -; CHECK: Cost Model: Found an estimated cost of 20 for instruction: %res8 = sdiv <4 x i8> undef, undef -; CHECK: Cost Model: Found an estimated cost of 20 for instruction: %res9 = sdiv <4 x i16> undef, undef -; CHECK: Cost Model: Found an estimated cost of 12 for instruction: %res10 = sdiv <4 x i32> undef, undef -; CHECK: Cost Model: Found an estimated cost of 6 for instruction: %res11 = sdiv <4 x i64> undef, undef -; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %res12 = sdiv <8 x i8> undef, undef -; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %res13 = sdiv <8 x i16> undef, undef -; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %res14 = sdiv <8 x i32> undef, undef -; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %res15 = sdiv <8 x i64> undef, undef -; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %res16 = sdiv <16 x i8> undef, undef -; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %res17 = sdiv <16 x i16> undef, undef -; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %res18 = sdiv <16 x i32> undef, undef -; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %res19 = sdiv <16 x i64> undef, undef - - ret void; -} - -define void @srem() { - %res0 = srem i8 undef, undef - %res1 = srem i16 undef, undef - %res2 = srem i32 undef, undef - %res3 = srem i64 undef, undef - %res4 = srem <2 x i8> undef, undef - %res5 = srem <2 x i16> undef, undef - %res6 = srem <2 x i32> undef, undef - %res7 = srem <2 x i64> undef, undef - %res8 = srem <4 x i8> undef, undef - %res9 = srem <4 x i16> undef, undef - %res10 = srem <4 x i32> undef, undef - %res11 = srem <4 x i64> undef, undef - %res12 = srem <8 x i8> undef, undef - %res13 = srem <8 x i16> undef, undef - %res14 = srem <8 x i32> undef, undef - %res15 = srem <8 x i64> undef, undef - %res16 = srem <16 x i8> undef, undef - %res17 = srem <16 x i16> undef, undef - %res18 = srem <16 x i32> undef, undef - %res19 = srem <16 x i64> undef, undef - -; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %res0 = srem i8 undef, undef -; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %res1 = srem i16 undef, undef -; CHECK: Cost Model: Found an estimated cost of 2 for instruction: %res2 = srem i32 undef, undef -; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %res3 = srem i64 undef, undef -; CHECK: Cost Model: Found an estimated cost of 10 for instruction: %res4 = srem <2 x i8> undef, undef -; CHECK: Cost Model: Found an estimated cost of 10 for instruction: %res5 = srem <2 x i16> undef, undef -; CHECK: Cost Model: Found an estimated cost of 6 for instruction: %res6 = srem <2 x i32> undef, undef -; CHECK: Cost Model: Found an estimated cost of 3 for instruction: %res7 = srem <2 x i64> undef, undef -; CHECK: Cost Model: Found an estimated cost of 20 for instruction: %res8 = srem <4 x i8> undef, undef -; CHECK: Cost Model: Found an estimated cost of 20 for instruction: %res9 = srem <4 x i16> undef, undef -; CHECK: Cost Model: Found an estimated cost of 12 for instruction: %res10 = srem <4 x i32> undef, undef -; CHECK: Cost Model: Found an estimated cost of 6 for instruction: %res11 = srem <4 x i64> undef, undef -; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %res12 = srem <8 x i8> undef, undef -; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %res13 = srem <8 x i16> undef, undef -; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %res14 = srem <8 x i32> undef, undef -; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %res15 = srem <8 x i64> undef, undef -; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %res16 = srem <16 x i8> undef, undef -; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %res17 = srem <16 x i16> undef, undef -; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %res18 = srem <16 x i32> undef, undef -; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %res19 = srem <16 x i64> undef, undef - - ret void; -} - -define void @udiv() { - %res0 = udiv i8 undef, undef - %res1 = udiv i16 undef, undef - %res2 = udiv i32 undef, undef - %res3 = udiv i64 undef, undef - %res4 = udiv <2 x i8> undef, undef - %res5 = udiv <2 x i16> undef, undef - %res6 = udiv <2 x i32> undef, undef - %res7 = udiv <2 x i64> undef, undef - %res8 = udiv <4 x i8> undef, undef - %res9 = udiv <4 x i16> undef, undef - %res10 = udiv <4 x i32> undef, undef - %res11 = udiv <4 x i64> undef, undef - %res12 = udiv <8 x i8> undef, undef - %res13 = udiv <8 x i16> undef, undef - %res14 = udiv <8 x i32> undef, undef - %res15 = udiv <8 x i64> undef, undef - %res16 = udiv <16 x i8> undef, undef - %res17 = udiv <16 x i16> undef, undef - %res18 = udiv <16 x i32> undef, undef - %res19 = udiv <16 x i64> undef, undef - -; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %res0 = udiv i8 undef, undef -; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %res1 = udiv i16 undef, undef -; CHECK: Cost Model: Found an estimated cost of 2 for instruction: %res2 = udiv i32 undef, undef -; CHECK: Cost Model: Found an estimated cost of 2 for instruction: %res3 = udiv i64 undef, undef -; CHECK: Cost Model: Found an estimated cost of 10 for instruction: %res4 = udiv <2 x i8> undef, undef -; CHECK: Cost Model: Found an estimated cost of 10 for instruction: %res5 = udiv <2 x i16> undef, undef -; CHECK: Cost Model: Found an estimated cost of 6 for instruction: %res6 = udiv <2 x i32> undef, undef -; CHECK: Cost Model: Found an estimated cost of 5 for instruction: %res7 = udiv <2 x i64> undef, undef -; CHECK: Cost Model: Found an estimated cost of 20 for instruction: %res8 = udiv <4 x i8> undef, undef -; CHECK: Cost Model: Found an estimated cost of 20 for instruction: %res9 = udiv <4 x i16> undef, undef -; CHECK: Cost Model: Found an estimated cost of 12 for instruction: %res10 = udiv <4 x i32> undef, undef -; CHECK: Cost Model: Found an estimated cost of 10 for instruction: %res11 = udiv <4 x i64> undef, undef -; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %res12 = udiv <8 x i8> undef, undef -; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %res13 = udiv <8 x i16> undef, undef -; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %res14 = udiv <8 x i32> undef, undef -; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %res15 = udiv <8 x i64> undef, undef -; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %res16 = udiv <16 x i8> undef, undef -; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %res17 = udiv <16 x i16> undef, undef -; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %res18 = udiv <16 x i32> undef, undef -; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %res19 = udiv <16 x i64> undef, undef - - ret void; -} - -define void @urem() { - %res0 = urem i8 undef, undef - %res1 = urem i16 undef, undef - %res2 = urem i32 undef, undef - %res3 = urem i64 undef, undef - %res4 = urem <2 x i8> undef, undef - %res5 = urem <2 x i16> undef, undef - %res6 = urem <2 x i32> undef, undef - %res7 = urem <2 x i64> undef, undef - %res8 = urem <4 x i8> undef, undef - %res9 = urem <4 x i16> undef, undef - %res10 = urem <4 x i32> undef, undef - %res11 = urem <4 x i64> undef, undef - %res12 = urem <8 x i8> undef, undef - %res13 = urem <8 x i16> undef, undef - %res14 = urem <8 x i32> undef, undef - %res15 = urem <8 x i64> undef, undef - %res16 = urem <16 x i8> undef, undef - %res17 = urem <16 x i16> undef, undef - %res18 = urem <16 x i32> undef, undef - %res19 = urem <16 x i64> undef, undef - -; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %res0 = urem i8 undef, undef -; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %res1 = urem i16 undef, undef -; CHECK: Cost Model: Found an estimated cost of 2 for instruction: %res2 = urem i32 undef, undef -; CHECK: Cost Model: Found an estimated cost of 2 for instruction: %res3 = urem i64 undef, undef -; CHECK: Cost Model: Found an estimated cost of 10 for instruction: %res4 = urem <2 x i8> undef, undef -; CHECK: Cost Model: Found an estimated cost of 10 for instruction: %res5 = urem <2 x i16> undef, undef -; CHECK: Cost Model: Found an estimated cost of 6 for instruction: %res6 = urem <2 x i32> undef, undef -; CHECK: Cost Model: Found an estimated cost of 5 for instruction: %res7 = urem <2 x i64> undef, undef -; CHECK: Cost Model: Found an estimated cost of 20 for instruction: %res8 = urem <4 x i8> undef, undef -; CHECK: Cost Model: Found an estimated cost of 20 for instruction: %res9 = urem <4 x i16> undef, undef -; CHECK: Cost Model: Found an estimated cost of 12 for instruction: %res10 = urem <4 x i32> undef, undef -; CHECK: Cost Model: Found an estimated cost of 10 for instruction: %res11 = urem <4 x i64> undef, undef -; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %res12 = urem <8 x i8> undef, undef -; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %res13 = urem <8 x i16> undef, undef -; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %res14 = urem <8 x i32> undef, undef -; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %res15 = urem <8 x i64> undef, undef -; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %res16 = urem <16 x i8> undef, undef -; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %res17 = urem <16 x i16> undef, undef -; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %res18 = urem <16 x i32> undef, undef -; CHECK: Cost Model: Found an estimated cost of 1000 for instruction: %res19 = urem <16 x i64> undef, undef - - ret void; -} Index: test/Analysis/CostModel/SystemZ/memop-folding-int-arith.ll =================================================================== --- test/Analysis/CostModel/SystemZ/memop-folding-int-arith.ll +++ test/Analysis/CostModel/SystemZ/memop-folding-int-arith.ll @@ -90,16 +90,16 @@ ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %4 = mul i64 %li64_0, %li64_1 } -define void @sdiv() { +define void @sdiv(i32 %arg32, i64 %arg64) { %li32 = load i32, i32* undef - sdiv i32 %li32, undef + sdiv i32 %li32, %arg32 %li32_0 = load i32, i32* undef %li32_1 = load i32, i32* undef sdiv i32 %li32_0, %li32_1 %li64 = load i64, i64* undef - sdiv i64 %li64, undef + sdiv i64 %li64, %arg64 %li64_0 = load i64, i64* undef %li64_1 = load i64, i64* undef @@ -107,27 +107,27 @@ ret void; ; CHECK: Cost Model: Found an estimated cost of 0 for instruction: %li32 = load i32, i32* undef -; CHECK: Cost Model: Found an estimated cost of 2 for instruction: %1 = sdiv i32 %li32, undef +; CHECK: Cost Model: Found an estimated cost of 21 for instruction: %1 = sdiv i32 %li32, %arg32 ; CHECK: Cost Model: Found an estimated cost of 0 for instruction: %li32_0 = load i32, i32* undef ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %li32_1 = load i32, i32* undef -; CHECK: Cost Model: Found an estimated cost of 2 for instruction: %2 = sdiv i32 %li32_0, %li32_1 +; CHECK: Cost Model: Found an estimated cost of 21 for instruction: %2 = sdiv i32 %li32_0, %li32_1 ; CHECK: Cost Model: Found an estimated cost of 0 for instruction: %li64 = load i64, i64* undef -; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %3 = sdiv i64 %li64, undef +; CHECK: Cost Model: Found an estimated cost of 20 for instruction: %3 = sdiv i64 %li64, %arg64 ; CHECK: Cost Model: Found an estimated cost of 0 for instruction: %li64_0 = load i64, i64* undef ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %li64_1 = load i64, i64* undef -; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %4 = sdiv i64 %li64_0, %li64_1 +; CHECK: Cost Model: Found an estimated cost of 20 for instruction: %4 = sdiv i64 %li64_0, %li64_1 } -define void @udiv() { +define void @udiv(i32 %arg32, i64 %arg64) { %li32 = load i32, i32* undef - udiv i32 %li32, undef + udiv i32 %li32, %arg32 %li32_0 = load i32, i32* undef %li32_1 = load i32, i32* undef udiv i32 %li32_0, %li32_1 %li64 = load i64, i64* undef - udiv i64 %li64, undef + udiv i64 %li64, %arg64 %li64_0 = load i64, i64* undef %li64_1 = load i64, i64* undef @@ -135,15 +135,15 @@ ret void; ; CHECK: Cost Model: Found an estimated cost of 0 for instruction: %li32 = load i32, i32* undef -; CHECK: Cost Model: Found an estimated cost of 2 for instruction: %1 = udiv i32 %li32, undef +; CHECK: Cost Model: Found an estimated cost of 21 for instruction: %1 = udiv i32 %li32, %arg32 ; CHECK: Cost Model: Found an estimated cost of 0 for instruction: %li32_0 = load i32, i32* undef ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %li32_1 = load i32, i32* undef -; CHECK: Cost Model: Found an estimated cost of 2 for instruction: %2 = udiv i32 %li32_0, %li32_1 +; CHECK: Cost Model: Found an estimated cost of 21 for instruction: %2 = udiv i32 %li32_0, %li32_1 ; CHECK: Cost Model: Found an estimated cost of 0 for instruction: %li64 = load i64, i64* undef -; CHECK: Cost Model: Found an estimated cost of 2 for instruction: %3 = udiv i64 %li64, undef +; CHECK: Cost Model: Found an estimated cost of 21 for instruction: %3 = udiv i64 %li64, %arg64 ; CHECK: Cost Model: Found an estimated cost of 0 for instruction: %li64_0 = load i64, i64* undef ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %li64_1 = load i64, i64* undef -; CHECK: Cost Model: Found an estimated cost of 2 for instruction: %4 = udiv i64 %li64_0, %li64_1 +; CHECK: Cost Model: Found an estimated cost of 21 for instruction: %4 = udiv i64 %li64_0, %li64_1 } define void @and() {