[llvm] r345321 - [SystemZ] Improve handling and cost estimates of vector integer div/rem

Jonas Paulsson via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 25 14:47:23 PDT 2018


Author: jonpa
Date: Thu Oct 25 14:47:22 2018
New Revision: 345321

URL: http://llvm.org/viewvc/llvm-project?rev=345321&view=rev
Log:
[SystemZ]  Improve handling and cost estimates of vector integer div/rem

Enable the DAG optimization that converts vector div/rem with constants into
multiply+shifts sequences by expanding them early. This is needed since
ISD::SMUL_LOHI is 'Custom' lowered on SystemZ, and will therefore not be
available to BuildSDIV after legalization.

Better cost values for these instructions based on how they will be
implemented (a constant divisor is cheaper).

Review: Ulrich Weigand
https://reviews.llvm.org/D53196

Added:
    llvm/trunk/test/Analysis/CostModel/SystemZ/divrem-const.ll
    llvm/trunk/test/Analysis/CostModel/SystemZ/divrem-pow2.ll
    llvm/trunk/test/Analysis/CostModel/SystemZ/divrem-reg.ll
Removed:
    llvm/trunk/test/Analysis/CostModel/SystemZ/div-pow2.ll
Modified:
    llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp
    llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.h
    llvm/trunk/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp
    llvm/trunk/test/Analysis/CostModel/SystemZ/int-arith.ll
    llvm/trunk/test/Analysis/CostModel/SystemZ/memop-folding-int-arith.ll

Modified: llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp?rev=345321&r1=345320&r2=345321&view=diff
==============================================================================
--- llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp Thu Oct 25 14:47:22 2018
@@ -527,6 +527,10 @@ SystemZTargetLowering::SystemZTargetLowe
   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 @@ SDValue SystemZTargetLowering::combineGE
   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 @@ SDValue SystemZTargetLowering::PerformDA
   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();

Modified: llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.h?rev=345321&r1=345320&r2=345321&view=diff
==============================================================================
--- llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.h (original)
+++ llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.h Thu Oct 25 14:47:22 2018
@@ -605,6 +605,7 @@ private:
   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.

Modified: llvm/trunk/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp?rev=345321&r1=345320&r2=345321&view=diff
==============================================================================
--- llvm/trunk/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp (original)
+++ llvm/trunk/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp Thu Oct 25 14:47:22 2018
@@ -362,27 +362,33 @@ int SystemZTTIImpl::getArithmeticInstrCo
 
   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<Constant>(Args[1])) {
-      if (C->getType()->isVectorTy())
-        CI = dyn_cast_or_null<const ConstantInt>(C->getSplatValue());
+      const ConstantInt *CVal =
+          (C->getType()->isVectorTy()
+               ? dyn_cast_or_null<const ConstantInt>(C->getSplatValue())
+               : dyn_cast<const ConstantInt>(C));
+      if (CVal != nullptr &&
+          (CVal->getValue().isPowerOf2() || (-CVal->getValue()).isPowerOf2()))
+        DivRemConstPow2 = true;
       else
-        CI = dyn_cast<const ConstantInt>(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 @@ int SystemZTTIImpl::getArithmeticInstrCo
     // 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 @@ int SystemZTTIImpl::getArithmeticInstrCo
       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.

Removed: llvm/trunk/test/Analysis/CostModel/SystemZ/div-pow2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/CostModel/SystemZ/div-pow2.ll?rev=345320&view=auto
==============================================================================
--- llvm/trunk/test/Analysis/CostModel/SystemZ/div-pow2.ll (original)
+++ llvm/trunk/test/Analysis/CostModel/SystemZ/div-pow2.ll (removed)
@@ -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, <i64 2, i64 2>
-  ret <2 x i64> %r
-; CHECK: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv <2 x i64> %a, <i64 2, i64 2>
-}
-
-define <2 x i64> @fun9(<2 x i64> %a) {
-  %r = sdiv <2 x i64> %a, <i64 -4, i64 -4>
-  ret <2 x i64> %r
-; CHECK: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv <2 x i64> %a, <i64 -4, i64 -4>
-}
-
-define <4 x i32> @fun10(<4 x i32> %a) {
-  %r = sdiv <4 x i32> %a, <i32 8, i32 8, i32 8, i32 8>
-  ret <4 x i32> %r
-; CHECK: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv <4 x i32> %a, <i32 8, i32 8, i32 8, i32 8>
-}
-
-define <4 x i32> @fun11(<4 x i32> %a) {
-  %r = sdiv <4 x i32> %a, <i32 -16, i32 -16, i32 -16, i32 -16>
-  ret <4 x i32> %r
-; CHECK: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv <4 x i32> %a, <i32 -16
-}
-
-define <8 x i16> @fun12(<8 x i16> %a) {
-  %r = sdiv <8 x i16> %a, <i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32>
-  ret <8 x i16> %r
-; CHECK: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv <8 x i16> %a, <i16 32
-}
-
-define <8 x i16> @fun13(<8 x i16> %a) {
-  %r = sdiv <8 x i16> %a, <i16 -64, i16 -64, i16 -64, i16 -64, i16 -64, i16 -64, i16 -64, i16 -64>
-  ret <8 x i16> %r
-; CHECK: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv <8 x i16> %a, <i16 -64
-}
-
-define <16 x i8> @fun14(<16 x i8> %a) {
-  %r = sdiv <16 x i8> %a, <i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64>
-  ret <16 x i8> %r
-; CHECK: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv <16 x i8> %a, <i8 64
-}
-
-define <16 x i8> @fun15(<16 x i8> %a) {
-  %r = sdiv <16 x i8> %a, <i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128>
-  ret <16 x i8> %r
-; CHECK: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv <16 x i8> %a, <i8 -128
-}
-
-; Scalar udiv
-
-define i64 @fun16(i64 %a) {
-  %r = udiv i64 %a, 2
-  ret i64 %r
-; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %r = udiv i64 %a, 2
-}
-
-define i32 @fun17(i32 %a) {
-  %r = udiv i32 %a, 8
-  ret i32 %r
-; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %r = udiv i32 %a, 8
-}
-
-define i16 @fun18(i16 %a) {
-  %r = udiv i16 %a, 32
-  ret i16 %r
-; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %r = udiv i16 %a, 32
-}
-
-define i8 @fun19(i8 %a) {
-  %r = udiv i8 %a, 128
-  ret i8 %r
-; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %r = udiv i8 %a, -128
-}
-
-; Vector udiv
-
-define <2 x i64> @fun20(<2 x i64> %a) {
-  %r = udiv <2 x i64> %a, <i64 2, i64 2>
-  ret <2 x i64> %r
-; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %r = udiv <2 x i64> %a, <i64 2
-}
-
-define <4 x i32> @fun21(<4 x i32> %a) {
-  %r = udiv <4 x i32> %a, <i32 8, i32 8, i32 8, i32 8>
-  ret <4 x i32> %r
-; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %r = udiv <4 x i32> %a, <i32 8
-}
-
-define <8 x i16> @fun22(<8 x i16> %a) {
-  %r = udiv <8 x i16> %a, <i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32>
-  ret <8 x i16> %r
-; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %r = udiv <8 x i16> %a, <i16 32
-}
-
-define <16 x i8> @fun23(<16 x i8> %a) {
-  %r = udiv <16 x i8> %a, <i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128>
-  ret <16 x i8> %r
-; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %r = udiv <16 x i8> %a, <i8 -128
-}

Added: llvm/trunk/test/Analysis/CostModel/SystemZ/divrem-const.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/CostModel/SystemZ/divrem-const.ll?rev=345321&view=auto
==============================================================================
--- llvm/trunk/test/Analysis/CostModel/SystemZ/divrem-const.ll (added)
+++ llvm/trunk/test/Analysis/CostModel/SystemZ/divrem-const.ll Thu Oct 25 14:47:22 2018
@@ -0,0 +1,291 @@
+; 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
+
+; Check costs of divisions/remainders by a vector of constants that is *not*
+; a power of two. A sequence containing a multiply and shifts will replace
+; the divide instruction.
+
+; Scalar sdiv
+
+define i64 @fun0(i64 %a) {
+  %r = sdiv i64 %a, 20
+  ret i64 %r
+; COST: Cost Model: Found an estimated cost of 10 for instruction:   %r = sdiv i64 %a, 20
+}
+
+define i32 @fun1(i32 %a) {
+  %r = sdiv i32 %a, 20
+  ret i32 %r
+; COST: Cost Model: Found an estimated cost of 10 for instruction:   %r = sdiv i32 %a, 20
+}
+
+define i16 @fun2(i16 %a) {
+  %r = sdiv i16 %a, 20
+  ret i16 %r
+; COST: Cost Model: Found an estimated cost of 10 for instruction:   %r = sdiv i16 %a, 20
+}
+
+define i8 @fun3(i8 %a) {
+  %r = sdiv i8 %a, 20
+  ret i8 %r
+; COST: Cost Model: Found an estimated cost of 10 for instruction:   %r = sdiv i8 %a, 20
+}
+
+; Vector sdiv
+
+define <2 x i64> @fun4(<2 x i64> %a) {
+  %r = sdiv <2 x i64> %a, <i64 20, i64 21>
+  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, <i32 20, i32 20, i32 20, i32 20>
+  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, <i32 20, i32 21>
+  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, <i16 20, i16 20, i16 20, i16 20, i16 20, i16 20, i16 20, i16 20>
+  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, <i16 20, i16 20, i16 20, i16 21>
+  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, <i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20>
+  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, <i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 21>
+  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, <i64 20, i64 20>
+  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, <i32 20, i32 20, i32 20, i32 21>
+  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, <i32 20, i32 20>
+  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, <i16 20, i16 20, i16 20, i16 20, i16 20, i16 20, i16 20, i16 21>
+  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, <i16 20, i16 20, i16 20, i16 20>
+  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, <i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 21>
+  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, <i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20>
+  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, <i64 20, i64 21>
+  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, <i32 20, i32 20, i32 20, i32 20>
+  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, <i32 20, i32 21>
+  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, <i16 20, i16 20, i16 20, i16 20, i16 20, i16 20, i16 20, i16 20>
+  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, <i16 20, i16 20, i16 20, i16 21>
+  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, <i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20>
+  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, <i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 21>
+  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, <i64 20, i64 20>
+  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, <i32 20, i32 20, i32 20, i32 21>
+  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, <i32 20, i32 20>
+  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, <i16 20, i16 20, i16 20, i16 20, i16 20, i16 20, i16 20, i16 21>
+  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, <i16 20, i16 20, i16 20, i16 20>
+  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, <i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 21>
+  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, <i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20>
+  ret <8 x i8> %r
+; COST: Cost Model: Found an estimated cost of 97 for instruction:   %r = urem <8 x i8>
+}

Added: llvm/trunk/test/Analysis/CostModel/SystemZ/divrem-pow2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/CostModel/SystemZ/divrem-pow2.ll?rev=345321&view=auto
==============================================================================
--- llvm/trunk/test/Analysis/CostModel/SystemZ/divrem-pow2.ll (added)
+++ llvm/trunk/test/Analysis/CostModel/SystemZ/divrem-pow2.ll Thu Oct 25 14:47:22 2018
@@ -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, <i64 2, i64 2>
+  ret <2 x i64> %r
+; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv <2 x i64> %a, <i64 2, i64 2>
+}
+
+define <2 x i64> @fun9(<2 x i64> %a) {
+  %r = sdiv <2 x i64> %a, <i64 -4, i64 -4>
+  ret <2 x i64> %r
+; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv <2 x i64> %a, <i64 -4, i64 -4>
+}
+
+define <4 x i32> @fun10(<4 x i32> %a) {
+  %r = sdiv <4 x i32> %a, <i32 8, i32 8, i32 8, i32 8>
+  ret <4 x i32> %r
+; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv <4 x i32> %a, <i32 8, i32 8, i32 8, i32 8>
+}
+
+define <4 x i32> @fun11(<4 x i32> %a) {
+  %r = sdiv <4 x i32> %a, <i32 -16, i32 -16, i32 -16, i32 -16>
+  ret <4 x i32> %r
+; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv <4 x i32> %a, <i32 -16
+}
+
+define <2 x i32> @fun12(<2 x i32> %a) {
+  %r = sdiv <2 x i32> %a, <i32 -16, i32 -16>
+  ret <2 x i32> %r
+; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv <2 x i32> %a, <i32 -16
+}
+
+define <8 x i16> @fun13(<8 x i16> %a) {
+  %r = sdiv <8 x i16> %a, <i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32>
+  ret <8 x i16> %r
+; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv <8 x i16> %a, <i16 32
+}
+
+define <8 x i16> @fun14(<8 x i16> %a) {
+  %r = sdiv <8 x i16> %a, <i16 -64, i16 -64, i16 -64, i16 -64, i16 -64, i16 -64, i16 -64, i16 -64>
+  ret <8 x i16> %r
+; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv <8 x i16> %a, <i16 -64
+}
+
+define <4 x i16> @fun15(<4 x i16> %a) {
+  %r = sdiv <4 x i16> %a, <i16 32, i16 32, i16 32, i16 32>
+  ret <4 x i16> %r
+; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv <4 x i16> %a, <i16 32
+}
+
+define <16 x i8> @fun16(<16 x i8> %a) {
+  %r = sdiv <16 x i8> %a, <i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64>
+  ret <16 x i8> %r
+; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv <16 x i8> %a, <i8 64
+}
+
+define <16 x i8> @fun17(<16 x i8> %a) {
+  %r = sdiv <16 x i8> %a, <i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128>
+  ret <16 x i8> %r
+; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv <16 x i8> %a, <i8 -128
+}
+
+define <8 x i8> @fun18(<8 x i8> %a) {
+  %r = sdiv <8 x i8> %a, <i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128>
+  ret <8 x i8> %r
+; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv <8 x i8> %a, <i8 -128
+}
+
+; Scalar udiv
+
+define i64 @fun19(i64 %a) {
+  %r = udiv i64 %a, 2
+  ret i64 %r
+; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = udiv i64 %a, 2
+}
+
+define i32 @fun20(i32 %a) {
+  %r = udiv i32 %a, 8
+  ret i32 %r
+; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = udiv i32 %a, 8
+}
+
+define i16 @fun21(i16 %a) {
+  %r = udiv i16 %a, 32
+  ret i16 %r
+; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = udiv i16 %a, 32
+}
+
+define i8 @fun22(i8 %a) {
+  %r = udiv i8 %a, 128
+  ret i8 %r
+; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = udiv i8 %a, -128
+}
+
+; Vector udiv
+
+define <2 x i64> @fun23(<2 x i64> %a) {
+  %r = udiv <2 x i64> %a, <i64 2, i64 2>
+  ret <2 x i64> %r
+; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = udiv <2 x i64> %a, <i64 2
+}
+
+define <4 x i32> @fun24(<4 x i32> %a) {
+  %r = udiv <4 x i32> %a, <i32 8, i32 8, i32 8, i32 8>
+  ret <4 x i32> %r
+; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = udiv <4 x i32> %a, <i32 8
+}
+
+define <2 x i32> @fun25(<2 x i32> %a) {
+  %r = udiv <2 x i32> %a, <i32 8, i32 8>
+  ret <2 x i32> %r
+; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = udiv <2 x i32> %a, <i32 8
+}
+
+define <8 x i16> @fun26(<8 x i16> %a) {
+  %r = udiv <8 x i16> %a, <i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32>
+  ret <8 x i16> %r
+; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = udiv <8 x i16> %a, <i16 32
+}
+
+define <4 x i16> @fun27(<4 x i16> %a) {
+  %r = udiv <4 x i16> %a, <i16 32, i16 32, i16 32, i16 32>
+  ret <4 x i16> %r
+; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = udiv <4 x i16> %a, <i16 32
+}
+
+define <16 x i8> @fun28(<16 x i8> %a) {
+  %r = udiv <16 x i8> %a, <i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128>
+  ret <16 x i8> %r
+; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = udiv <16 x i8> %a, <i8 -128
+}
+
+define <8 x i8> @fun29(<8 x i8> %a) {
+  %r = udiv <8 x i8> %a, <i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128>
+  ret <8 x i8> %r
+; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = udiv <8 x i8> %a, <i8 -128
+}
+
+; Scalar srem
+
+define i64 @fun30(i64 %a) {
+  %r = srem i64 %a, 2
+  ret i64 %r
+; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem i64 %a, 2
+}
+
+define i64 @fun31(i64 %a) {
+  %r = srem i64 %a, -4
+  ret i64 %r
+; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem i64 %a, -4
+}
+
+define i32 @fun32(i32 %a) {
+  %r = srem i32 %a, 8
+  ret i32 %r
+; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem i32 %a, 8
+}
+
+define i32 @fun33(i32 %a) {
+  %r = srem i32 %a, -16
+  ret i32 %r
+; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem i32 %a, -16
+}
+
+define i16 @fun34(i16 %a) {
+  %r = srem i16 %a, 32
+  ret i16 %r
+; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem i16 %a, 32
+}
+
+define i16 @fun35(i16 %a) {
+  %r = srem i16 %a, -64
+  ret i16 %r
+; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem i16 %a, -64
+}
+
+define i8 @fun36(i8 %a) {
+  %r = srem i8 %a, 64
+  ret i8 %r
+; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem i8 %a, 64
+}
+
+define i8 @fun37(i8 %a) {
+  %r = srem i8 %a, -128
+  ret i8 %r
+; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem i8 %a, -128
+}
+
+; Vector srem
+
+define <2 x i64> @fun38(<2 x i64> %a) {
+  %r = srem <2 x i64> %a, <i64 2, i64 2>
+  ret <2 x i64> %r
+; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem <2 x i64> %a, <i64 2, i64 2>
+}
+
+define <2 x i64> @fun39(<2 x i64> %a) {
+  %r = srem <2 x i64> %a, <i64 -4, i64 -4>
+  ret <2 x i64> %r
+; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem <2 x i64> %a, <i64 -4, i64 -4>
+}
+
+define <4 x i32> @fun40(<4 x i32> %a) {
+  %r = srem <4 x i32> %a, <i32 8, i32 8, i32 8, i32 8>
+  ret <4 x i32> %r
+; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem <4 x i32> %a, <i32 8, i32 8, i32 8, i32 8>
+}
+
+define <4 x i32> @fun41(<4 x i32> %a) {
+  %r = srem <4 x i32> %a, <i32 -16, i32 -16, i32 -16, i32 -16>
+  ret <4 x i32> %r
+; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem <4 x i32> %a, <i32 -16
+}
+
+define <2 x i32> @fun42(<2 x i32> %a) {
+  %r = srem <2 x i32> %a, <i32 -16, i32 -16>
+  ret <2 x i32> %r
+; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem <2 x i32> %a, <i32 -16
+}
+
+define <8 x i16> @fun43(<8 x i16> %a) {
+  %r = srem <8 x i16> %a, <i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32>
+  ret <8 x i16> %r
+; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem <8 x i16> %a, <i16 32
+}
+
+define <8 x i16> @fun44(<8 x i16> %a) {
+  %r = srem <8 x i16> %a, <i16 -64, i16 -64, i16 -64, i16 -64, i16 -64, i16 -64, i16 -64, i16 -64>
+  ret <8 x i16> %r
+; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem <8 x i16> %a, <i16 -64
+}
+
+define <4 x i16> @fun45(<4 x i16> %a) {
+  %r = srem <4 x i16> %a, <i16 32, i16 32, i16 32, i16 32>
+  ret <4 x i16> %r
+; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem <4 x i16> %a, <i16 32
+}
+
+define <16 x i8> @fun46(<16 x i8> %a) {
+  %r = srem <16 x i8> %a, <i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64>
+  ret <16 x i8> %r
+; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem <16 x i8> %a, <i8 64
+}
+
+define <16 x i8> @fun47(<16 x i8> %a) {
+  %r = srem <16 x i8> %a, <i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128>
+  ret <16 x i8> %r
+; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem <16 x i8> %a, <i8 -128
+}
+
+define <8 x i8> @fun48(<8 x i8> %a) {
+  %r = srem <8 x i8> %a, <i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128>
+  ret <8 x i8> %r
+; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem <8 x i8> %a, <i8 -128
+}
+
+; Scalar urem
+
+define i64 @fun49(i64 %a) {
+  %r = urem i64 %a, 2
+  ret i64 %r
+; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = urem i64 %a, 2
+}
+
+define i32 @fun50(i32 %a) {
+  %r = urem i32 %a, 8
+  ret i32 %r
+; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = urem i32 %a, 8
+}
+
+define i16 @fun51(i16 %a) {
+  %r = urem i16 %a, 32
+  ret i16 %r
+; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = urem i16 %a, 32
+}
+
+define i8 @fun52(i8 %a) {
+  %r = urem i8 %a, 128
+  ret i8 %r
+; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = urem i8 %a, -128
+}
+
+; Vector urem
+
+define <2 x i64> @fun53(<2 x i64> %a) {
+  %r = urem <2 x i64> %a, <i64 2, i64 2>
+  ret <2 x i64> %r
+; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = urem <2 x i64> %a, <i64 2
+}
+
+define <4 x i32> @fun54(<4 x i32> %a) {
+  %r = urem <4 x i32> %a, <i32 8, i32 8, i32 8, i32 8>
+  ret <4 x i32> %r
+; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = urem <4 x i32> %a, <i32 8
+}
+
+define <2 x i32> @fun55(<2 x i32> %a) {
+  %r = urem <2 x i32> %a, <i32 8, i32 8>
+  ret <2 x i32> %r
+; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = urem <2 x i32> %a, <i32 8
+}
+
+define <8 x i16> @fun56(<8 x i16> %a) {
+  %r = urem <8 x i16> %a, <i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32>
+  ret <8 x i16> %r
+; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = urem <8 x i16> %a, <i16 32
+}
+
+define <4 x i16> @fun57(<4 x i16> %a) {
+  %r = urem <4 x i16> %a, <i16 32, i16 32, i16 32, i16 32>
+  ret <4 x i16> %r
+; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = urem <4 x i16> %a, <i16 32
+}
+
+define <16 x i8> @fun58(<16 x i8> %a) {
+  %r = urem <16 x i8> %a, <i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128>
+  ret <16 x i8> %r
+; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = urem <16 x i8> %a, <i8 -128
+}
+
+define <8 x i8> @fun59(<8 x i8> %a) {
+  %r = urem <8 x i8> %a, <i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128>
+  ret <8 x i8> %r
+; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = urem <8 x i8> %a, <i8 -128
+}

Added: llvm/trunk/test/Analysis/CostModel/SystemZ/divrem-reg.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/CostModel/SystemZ/divrem-reg.ll?rev=345321&view=auto
==============================================================================
--- llvm/trunk/test/Analysis/CostModel/SystemZ/divrem-reg.ll (added)
+++ llvm/trunk/test/Analysis/CostModel/SystemZ/divrem-reg.ll Thu Oct 25 14:47:22 2018
@@ -0,0 +1,286 @@
+; RUN: opt < %s -cost-model -analyze -mtriple=systemz-unknown -mcpu=z13 | FileCheck %s
+
+; Check costs of divisions by register
+;
+; Note: Vectorization of division/remainder is temporarily disabled for high
+; vectorization factors by returning 1000.
+
+; Scalar sdiv
+
+define i64 @fun0(i64 %a, i64 %b) {
+  %r = sdiv i64 %a, %b
+  ret i64 %r
+; CHECK: Cost Model: Found an estimated cost of 20 for instruction:   %r = sdiv i64
+}
+
+define i32 @fun1(i32 %a, i32 %b) {
+  %r = sdiv i32 %a, %b
+  ret i32 %r
+; CHECK: Cost Model: Found an estimated cost of 21 for instruction:   %r = sdiv i32 %a, %b
+}
+
+define i16 @fun2(i16 %a, i16 %b) {
+  %r = sdiv i16 %a, %b
+  ret i16 %r
+; CHECK: Cost Model: Found an estimated cost of 23 for instruction:   %r = sdiv i16 %a, %b
+}
+
+define i8 @fun3(i8 %a, i8 %b) {
+  %r = sdiv i8 %a, %b
+  ret i8 %r
+; CHECK: Cost Model: Found an estimated cost of 23 for instruction:   %r = sdiv i8 %a, %b
+}
+
+; Vector sdiv
+
+define <2 x i64> @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>
+}

Modified: llvm/trunk/test/Analysis/CostModel/SystemZ/int-arith.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/CostModel/SystemZ/int-arith.ll?rev=345321&r1=345320&r2=345321&view=diff
==============================================================================
--- llvm/trunk/test/Analysis/CostModel/SystemZ/int-arith.ll (original)
+++ llvm/trunk/test/Analysis/CostModel/SystemZ/int-arith.ll Thu Oct 25 14:47:22 2018
@@ -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 @@ define void @mul() {
 
   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;
-}

Modified: llvm/trunk/test/Analysis/CostModel/SystemZ/memop-folding-int-arith.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/CostModel/SystemZ/memop-folding-int-arith.ll?rev=345321&r1=345320&r2=345321&view=diff
==============================================================================
--- llvm/trunk/test/Analysis/CostModel/SystemZ/memop-folding-int-arith.ll (original)
+++ llvm/trunk/test/Analysis/CostModel/SystemZ/memop-folding-int-arith.ll Thu Oct 25 14:47:22 2018
@@ -90,16 +90,16 @@ define void @mul() {
 ; 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 @@ define void @sdiv() {
 
   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 @@ define void @udiv() {
 
   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() {




More information about the llvm-commits mailing list