summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorNadav Rotem <nrotem@apple.com>2012-12-04 07:11:52 +0000
committerNadav Rotem <nrotem@apple.com>2012-12-04 07:11:52 +0000
commit07674cb566e50abf5e09cb54b0f0f745782fd4b1 (patch)
tree0cd84a0aed86f1a7ade6d8246bf27bf65a976e61 /llvm/lib
parent43342d5c88fa06ee22eeaae6a373199ea8c54fb1 (diff)
downloadbcm5719-llvm-07674cb566e50abf5e09cb54b0f0f745782fd4b1.tar.gz
bcm5719-llvm-07674cb566e50abf5e09cb54b0f0f745782fd4b1.zip
Give scalar if-converted blocks half the score because they are not always executed due to CF.
llvm-svn: 169223
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Vectorize/LoopVectorize.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index f538e081793..1de5b30c0ef 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -2159,17 +2159,17 @@ unsigned LoopVectorizationCostModel::expectedCost(unsigned VF) {
// For each instruction in the old loop.
for (BasicBlock::iterator it = BB->begin(), e = BB->end(); it != e; ++it) {
-
unsigned C = getInstructionCost(it, VF);
Cost += C;
DEBUG(dbgs() << "LV: Found an estimated cost of "<< C <<" for VF " <<
VF << " For instruction: "<< *it << "\n");
}
- // TODO: if-converted blocks can have a high-nest level. We need to
- // calculate the loop nest level and multiply the cost accordingly.
- if (Legal->blockNeedsPredication(*bb))
- BlockCost *= 2;
+ // We assume that if-converted blocks have a 50% chance of being executed.
+ // When the code is scalar then some of the blocks are avoided due to CF.
+ // When the code is vectorized we execute all code paths.
+ if (Legal->blockNeedsPredication(*bb) && VF == 1)
+ BlockCost /= 2;
Cost += BlockCost;
}
OpenPOWER on IntegriCloud