[llvm] [SCCP] Relax 2-insts range check to one-icmp check (PR #187997)

Kunqiu Chen via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 3 01:35:41 PDT 2026


================
@@ -105,6 +105,112 @@ static ConstantRange getRange(Value *Op, SCCPSolver &Solver,
                                                        /*UndefAllowed=*/false);
 }
 
+/// SCCP already proves x \in KnownCR, so only ActiveCmpCR = CmpCR ∩ KnownCR
+/// matters. Try to replace CmpCR with a simpler equivalent range NewCmpCR
+/// such that NewCmpCR ∩ KnownCR == ActiveCmpCR.
----------------
Camsyn wrote:

In fact, simplifying `CmpCR ∩ KnownCR` is equivalent to simplifying `CmpCR.inverse() ∩ KnownCR`.
Let `R = CmpCR ∩ KnownCR, R' = CmpCR.inverse() ∩ KnownCR`, we have $R = \text{CmpCR} \setminus R'$.

And I cannot find any case where $R'$ can be simplified while $R$ cannot.

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


More information about the llvm-commits mailing list