[llvm-commits] [llvm] r169223 - /llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
Hal Finkel
hfinkel at anl.gov
Tue Dec 4 09:41:36 PST 2012
----- Original Message -----
> From: "Nadav Rotem" <nrotem at apple.com>
> To: llvm-commits at cs.uiuc.edu
> Sent: Tuesday, December 4, 2012 1:11:52 AM
> Subject: [llvm-commits] [llvm] r169223 - /llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
>
> 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.
Should we make use of branch weights here? If nothing else, LowerExpectIntrinsic transforms uses of __builtin_expect into branch weights.
-Hal
>
> 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;
> }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
--
Hal Finkel
Postdoctoral Appointee
Leadership Computing Facility
Argonne National Laboratory
More information about the llvm-commits
mailing list