[PATCH] D20115: Loop unroller: set thresholds for optsize and minsize functions to zero

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Tue May 10 11:05:18 PDT 2016


hans added inline comments.

================
Comment at: test/Transforms/LoopUnroll/unroll-opt-attribute.ll:7-10
@@ -6,6 +6,6 @@
 
-; This test shows that with optsize attribute, the loop is unrolled
-; according to the specified unroll factor.
+; This test shows that the loop is unrolled according to the specified
+; unroll factor.
 
-define void @Test1() nounwind optsize {
+define void @Test1() nounwind {
 entry:
----------------
hans wrote:
> rnk wrote:
> > mamai wrote:
> > > This test should not need to be modified if the #pragma unroll still works in /Os... The -unroll-count=4 should simulate the unroll pragma, and therefor the loop should be unrolled even if the optsize attribute is there.
> > Sounds like the LLVM pass is misbehaving then, and we should revert the clang side change to enable the loop unroller until this is addressed in LLVM.
> I'm looking into it. I'm not sure the -unroll-count flag and the pragma do the same thing. Maybe this is easy to fix..
Yeah, -unroll-count does not simulate the pragma (is it supposed to?). It does set the count, but it doesn't modify the thresholds, whereas the pragma does:

```
  if (PragmaCount > 0 ||
      ((PragmaFullUnroll || PragmaEnableUnroll) && TripCount != 0)) {                                                                    
    // If the loop has an unrolling pragma, we want to be more aggressive with                                                           
    // unrolling limits. Set thresholds to at least the PragmaTheshold value                                                             
    // which is larger than the default limits.                                                                                          
    if (UP.Threshold != NoThreshold)                                                                                                     
      UP.Threshold = std::max<unsigned>(UP.Threshold, PragmaUnrollThreshold);                                                            
    if (UP.PartialThreshold != NoThreshold)                                                                                              
      UP.PartialThreshold =
          std::max<unsigned>(UP.PartialThreshold, PragmaUnrollThreshold);                                                                
  } 
```

The pragmas are tested in test/Transforms/LoopUnroll/unroll-pragmas.ll I'll add a test there for the optsize case.


http://reviews.llvm.org/D20115





More information about the llvm-commits mailing list