diff options
author | Nadav Rotem <nrotem@apple.com> | 2012-12-04 07:11:52 +0000 |
---|---|---|
committer | Nadav Rotem <nrotem@apple.com> | 2012-12-04 07:11:52 +0000 |
commit | e6f2df961065e3b723ef0fc78441f07c5577acd2 (patch) | |
tree | 39393381b0b4fdddf42efb0f31af24007c20f10f /lib/Transforms/Vectorize/LoopVectorize.cpp | |
parent | 6cb571968901701212570cbb2ab34cf4af6ba51e (diff) |
Give scalar if-converted blocks half the score because they are not always executed due to CF.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169223 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Vectorize/LoopVectorize.cpp')
-rw-r--r-- | lib/Transforms/Vectorize/LoopVectorize.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/Transforms/Vectorize/LoopVectorize.cpp b/lib/Transforms/Vectorize/LoopVectorize.cpp index f538e08179..1de5b30c0e 100644 --- a/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/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; } |