[PATCH] D15559: [LoopUnrollRuntime] Do unroll when the unroll factor is 2

Junmo Park via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 16 00:59:26 PST 2015


flyingforyou created this revision.
flyingforyou added reviewers: jmolloy, zzheng.
flyingforyou added a subscriber: llvm-commits.

When the unroll factor is 2, there is no division for computing loop's runtime trip-count.
This patch gives 0.3~0.5% performance improvements on benchmarks(test-suite, spec2000, commercial benchmark)

http://reviews.llvm.org/D15559

Files:
  lib/Transforms/Utils/LoopUnrollRuntime.cpp

Index: lib/Transforms/Utils/LoopUnrollRuntime.cpp
===================================================================
--- lib/Transforms/Utils/LoopUnrollRuntime.cpp
+++ lib/Transforms/Utils/LoopUnrollRuntime.cpp
@@ -313,7 +313,10 @@
   BasicBlock *Header = L->getHeader();
   const DataLayout &DL = Header->getModule()->getDataLayout();
   SCEVExpander Expander(*SE, DL, "loop-unroll");
-  if (!AllowExpensiveTripCount && Expander.isHighCostExpansion(TripCountSC, L))
+
+  // When the unroll factor is 2, we don't need to check cost expansion.
+  if (Count != 2 && !AllowExpensiveTripCount &&
+      Expander.isHighCostExpansion(TripCountSC, L))
     return false;
 
   // We only handle cases when the unroll factor is a power of 2.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15559.42961.patch
Type: text/x-patch
Size: 734 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151216/e59c37a6/attachment.bin>


More information about the llvm-commits mailing list