[llvm] [LoopUnroll] Enable allowexpensivetripcounts when user provides pragma (PR #181267)

Justin Fargnoli via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 13 18:02:02 PDT 2026


================
@@ -1008,19 +1048,23 @@ bool llvm::computeUnrollCount(Loop *L, const TargetTransformInfo &TTI,
     UP.Runtime = false;
     return true;
   }
+  // If a user provided an explicit unroll pragma (with or without count),
+  // enable runtime unrolling and override expensive trip count checks.
+  if (PragmaEnableUnroll || PragmaCount > 0) {
+    UP.AllowExpensiveTripCount = true;
+    UP.Runtime = true;
+  }
   // Check for explicit Count.
----------------
justinfargnoli wrote:

```suggestion
}

  // If a user provided an explicit unroll pragma (with or without count),
  // enable runtime unrolling and override expensive trip count checks.
  if (PragmaEnableUnroll || PragmaCount > 0) {
    UP.AllowExpensiveTripCount = true;
    UP.Runtime = true;
  }
  
// Check for explicit Count.
```

https://github.com/llvm/llvm-project/pull/181267


More information about the llvm-commits mailing list