[llvm] [IndVarSimplify] Fix `IndVarSimplify` to skip on unfolding predicates when the loop contains control convergence operations. (PR #165643)

Steven Perron via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 31 06:40:41 PDT 2025


================
@@ -1859,6 +1860,18 @@ bool IndVarSimplify::predicateLoopExits(Loop *L, SCEVExpander &Rewriter) {
         }
       }
 
+  CodeMetrics Metrics;
+  SmallPtrSet<const Value *, 32> EphValues;
+  for (BasicBlock *BB : L->blocks()) {
+    Metrics.analyzeBasicBlock(BB, *TTI, EphValues, /* PrepareForLTO= */ false,
+                              L);
+  }
----------------
s-perron wrote:

This might be overkill. I believe the convergence token has to be defined in the loop header. The code metics does more than is needed. However, you can use the code in codemetrics.cpp as a guide on how to implement what is needed in this pass.

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


More information about the llvm-commits mailing list