summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/LoopUnroll/X86
diff options
context:
space:
mode:
authorJingyue Wu <jingyue@google.com>2015-07-26 17:28:13 +0000
committerJingyue Wu <jingyue@google.com>2015-07-26 17:28:13 +0000
commitbf485f059cccef6b6ff90aa23ad8523688c8b189 (patch)
tree8635080289cfb57d50ed2efb210e0e50c6d060bd /llvm/test/Transforms/LoopUnroll/X86
parent65d35a14b7d28aa3462af83d391a5039cc52a842 (diff)
downloadbcm5719-llvm-bf485f059cccef6b6ff90aa23ad8523688c8b189.tar.gz
bcm5719-llvm-bf485f059cccef6b6ff90aa23ad8523688c8b189.zip
[TTI/CostModel] improve TTI::getGEPCost and use it in CostModel::getInstructionCost
Summary: This patch updates TargetTransformInfoImplCRTPBase::getGEPCost to consider addressing modes. It now returns TCC_Free when the GEP can be completely folded to an addresing mode. I started this patch as I refactored SLSR. Function isGEPFoldable looks common and is indeed used by some WIP of mine. So I extracted that logic to getGEPCost. Furthermore, I noticed getGEPCost wasn't directly tested anywhere. The best testing bed seems CostModel, but its getInstructionCost method invokes getAddressComputationCost for GEPs which provides very coarse estimation. So this patch also makes getInstructionCost call the updated getGEPCost for GEPs. This change inevitably breaks some tests because the cost model changes, but nothing looks seriously wrong -- if we believe the new cost model is the right way to go, these tests should be updated. This patch is not perfect yet -- the comments in some tests need to be updated. I want to know whether this is a right approach before fixing those details. Reviewers: chandlerc, hfinkel Subscribers: aschwaighofer, llvm-commits, aemerson Differential Revision: http://reviews.llvm.org/D9819 llvm-svn: 243250
Diffstat (limited to 'llvm/test/Transforms/LoopUnroll/X86')
-rw-r--r--llvm/test/Transforms/LoopUnroll/X86/partial.ll9
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/test/Transforms/LoopUnroll/X86/partial.ll b/llvm/test/Transforms/LoopUnroll/X86/partial.ll
index 4566f792deb..104a38779e5 100644
--- a/llvm/test/Transforms/LoopUnroll/X86/partial.ll
+++ b/llvm/test/Transforms/LoopUnroll/X86/partial.ll
@@ -86,17 +86,20 @@ for.body: ; preds = %entry, %for.body
%reduction.026 = phi i16 [ %add14, %for.body ], [ 0, %entry ]
%arrayidx = getelementptr inbounds i16, i16* %arr, i64 %indvars.iv
%0 = load i16, i16* %arrayidx, align 2
- %add = add i16 %0, %reduction.026
+ %mul = shl i16 %0, 1
+ %add = add i16 %mul, %reduction.026
%sext = mul i64 %indvars.iv, 12884901888
%idxprom3 = ashr exact i64 %sext, 32
%arrayidx4 = getelementptr inbounds i16, i16* %arr, i64 %idxprom3
%1 = load i16, i16* %arrayidx4, align 2
- %add7 = add i16 %add, %1
+ %mul2 = shl i16 %1, 1
+ %add7 = add i16 %add, %mul2
%sext28 = mul i64 %indvars.iv, 21474836480
%idxprom10 = ashr exact i64 %sext28, 32
%arrayidx11 = getelementptr inbounds i16, i16* %arr, i64 %idxprom10
%2 = load i16, i16* %arrayidx11, align 2
- %add14 = add i16 %add7, %2
+ %mul3 = shl i16 %2, 1
+ %add14 = add i16 %add7, %mul3
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%lftr.wideiv = trunc i64 %indvars.iv.next to i32
%exitcond = icmp eq i32 %lftr.wideiv, %n
OpenPOWER on IntegriCloud