[llvm] [HashRecognize] Track visited in ValueEvolution (PR #147812)

Piotr Fusik via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 14 02:57:32 PDT 2025


================
@@ -185,9 +199,14 @@ KnownBits ValueEvolution::computeInstr(const Instruction *I) {
   // Compute the KnownBits for a Select(Cmp()), forcing it to take the branch
   // that is predicated on the (least|most)-significant-bit check.
   CmpPredicate Pred;
-  Value *L, *R, *TV, *FV;
-  if (match(I, m_Select(m_ICmp(Pred, m_Value(L), m_Value(R)), m_Value(TV),
-                        m_Value(FV)))) {
+  Value *L, *R;
+  Instruction *TV, *FV;
+  if (match(I, m_Select(m_ICmp(Pred, m_Value(L), m_Value(R)), m_Instruction(TV),
+                        m_Instruction(FV)))) {
+    Visited.insert(cast<Instruction>(I->getOperand(0)));
+    Visited.insert(TV);
+    Visited.insert(FV);
+
     // We need to check LCR against [0, 2) in the little-endian case, because
     // the RCR check is insufficient: it is simply [0, 1).
     if (!ByteOrderSwapped) {
----------------
pfusik wrote:

Oops, indeed in my last comment I looked at a wrong test and a wrong `icmp` (exit cond instead of check sb).

But my point from previous comments remains valid:
```
if (match(I, m_Select(m_ICmp(Pred, m_Value(L), m_Value(R)), m_Instruction(TV),
                        m_Instruction(FV)))) {
```
matches `L`, but there's no `compute(L)`. Can we test and handle a case where L has side effects?

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


More information about the llvm-commits mailing list