[PATCH] Do not add unroll disable metadata after unrolling pass for loops with #pragma clang loop unroll(full)

Jingyue Wu jingyue at google.com
Wed Jul 23 12:01:12 PDT 2014


LGTM with some minor comments. Thanks!

================
Comment at: lib/Transforms/Scalar/LoopUnrollPass.cpp:460
@@ -459,4 +459,3 @@
   if (HasPragma) {
-    // Mark loop as unrolled to prevent unrolling beyond that
-    // requested by the pragma.
-    SetLoopAlreadyUnrolled(L);
+    if (PragmaCount)
+      // If loop has an unroll count pragma mark loop as unrolled to prevent
----------------
I'd say PragmaCount != 0 because it's an integer. 

================
Comment at: test/Transforms/LoopUnroll/unroll-pragmas-disabled.ll:41
@@ -42,1 +40,3 @@
+; An unroll disable metadata node is only added for the unroll count case.
+; In this case, metadata should not change.
 ;
----------------
To be clear, can we explain why this loop cannot be unrolled? 

================
Comment at: test/Transforms/LoopUnroll/unroll-pragmas-disabled.ll:56
@@ -55,1 +55,3 @@
   %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
+  %exitcond = icmp eq i64 %indvars.iv.next, 1000000
+  br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !5
----------------
Would it be better if we make the trip count a variable, so that the loop can't be unrolled regardless of the threshold? I think that would make the test more resilience.

http://reviews.llvm.org/D4643






More information about the llvm-commits mailing list