[PATCH] Fix bug causing loop unrolling to be disabled in some cases for loops with '#pragma clang loop unroll_count(N)"

Mark Heffernan meheff at google.com
Thu Jul 24 14:59:24 PDT 2014

Hi hfinkel,

After unrolling a loop with llvm.loop.unroll.count metadata (unroll factor hint) the loop unroller replaces the llvm.loop.unroll.count metadata with llvm.loop.unroll.disable metadata to prevent any subsequent unrolling passes from unrolling more than the hint indicates.  However, if the unroll count metadata is shared between loops then unrolling for these other loops will also be disabled.  This small patch fixes that problem by adding the llvm.loop.unroll.disable metadata to only the loop which was just unrolled.



Index: lib/Transforms/Scalar/LoopUnrollPass.cpp
--- lib/Transforms/Scalar/LoopUnrollPass.cpp
+++ lib/Transforms/Scalar/LoopUnrollPass.cpp
@@ -302,7 +302,6 @@
   // Set operand 0 to refer to the loop id itself.
   NewLoopID->replaceOperandWith(0, NewLoopID);
-  LoopID->replaceAllUsesWith(NewLoopID);
 unsigned LoopUnroll::selectUnrollCount(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4662.11856.patch
Type: text/x-patch
Size: 442 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140724/bb21fd0a/attachment.bin>

More information about the llvm-commits mailing list