[llvm-commits] [llvm] r169223 - /llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
Nadav Rotem
nrotem at apple.com
Mon Dec 3 23:11:52 PST 2012
Author: nadav
Date: Tue Dec 4 01:11:52 2012
New Revision: 169223
URL: http://llvm.org/viewvc/llvm-project?rev=169223&view=rev
Log:
Give scalar if-converted blocks half the score because they are not always executed due to CF.
Modified:
llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
Modified: llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp?rev=169223&r1=169222&r2=169223&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp (original)
+++ llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp Tue Dec 4 01:11:52 2012
@@ -2159,17 +2159,17 @@
// 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;
}
More information about the llvm-commits
mailing list