[PATCH] D29631: SystemZTargetTransformInfo cost functions and some common code changes

Jonas Paulsson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 22 08:00:24 PST 2017


jonpa updated this revision to Diff 89362.
jonpa marked 2 inline comments as done.
jonpa added a comment.

Patch updated according to review.

CostModel tests added. The CostModel tests reflect the current costsl while using undef operands extensively, which makes the returned values lower than what is typical, for the scalarized instructions. Would it be better to rewrite these tests to use a separate function with arguments for each case, to include the operands extraction cost?

The tests depend on a patch for getOperandsScalarizationOverhead(), for it to handle vector type arguments, when it's called by CostModel:

http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20170220/432062.html:
diff --git a/include/llvm/CodeGen/BasicTTIImpl.h b/include/llvm/CodeGen/BasicTTIImpl.h
index d9131da..12f67f9 100644

- a/include/llvm/CodeGen/BasicTTIImpl.h

+++ b/include/llvm/CodeGen/BasicTTIImpl.h
@@ -312,9 +312,16 @@ public:

  unsigned Cost = 0;
  SmallPtrSet<const Value*, 4> UniqueOperands;
  for (const Value *A : Args) {

- if (UniqueOperands.insert(A).second)
- Cost += getScalarizationOverhead(VectorType::get(A->getType(), VF),
- false, true);

+      if (!isa<UndefValue>(A) && UniqueOperands.insert(A).second) {
+        Type *VecTy = nullptr;
+        if (A->getType()->isVectorTy()) {
+          assert (VF == A->getType()->getVectorNumElements());
+          VecTy = A->getType();
+        }
+        else
+          VecTy = VectorType::get(A->getType(), VF);
+        Cost += getScalarizationOverhead(VecTy, false, true);
+      }

    }
    return Cost;
  }


https://reviews.llvm.org/D29631

Files:
  include/llvm/Analysis/TargetTransformInfo.h
  include/llvm/Analysis/TargetTransformInfoImpl.h
  include/llvm/CodeGen/BasicTTIImpl.h
  lib/Analysis/CostModel.cpp
  lib/Analysis/TargetTransformInfo.cpp
  lib/Target/AArch64/AArch64TargetTransformInfo.cpp
  lib/Target/AArch64/AArch64TargetTransformInfo.h
  lib/Target/ARM/ARMTargetTransformInfo.cpp
  lib/Target/ARM/ARMTargetTransformInfo.h
  lib/Target/PowerPC/PPCTargetTransformInfo.cpp
  lib/Target/PowerPC/PPCTargetTransformInfo.h
  lib/Target/SystemZ/SystemZISelLowering.cpp
  lib/Target/SystemZ/SystemZTargetTransformInfo.cpp
  lib/Target/SystemZ/SystemZTargetTransformInfo.h
  lib/Target/X86/X86TargetTransformInfo.cpp
  lib/Target/X86/X86TargetTransformInfo.h
  lib/Transforms/Vectorize/LoopVectorize.cpp
  test/Analysis/CostModel/SystemZ/cmpsel.ll
  test/Analysis/CostModel/SystemZ/fp-arith.ll
  test/Analysis/CostModel/SystemZ/fp-cast.ll
  test/Analysis/CostModel/SystemZ/int-arith.ll
  test/Analysis/CostModel/SystemZ/int-cast.ll
  test/Analysis/CostModel/SystemZ/load_store.ll
  test/Analysis/CostModel/SystemZ/logical.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29631.89362.patch
Type: text/x-patch
Size: 232428 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170222/7291f03d/attachment-0001.bin>


More information about the llvm-commits mailing list