[llvm] [ValueTracking] isNonZero sub of ptr2int's with recursive GEP (PR #68680)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 20 02:18:32 PST 2023


================
@@ -3199,6 +3199,14 @@ static bool isKnownNonEqual(const Value *V1, const Value *V2, unsigned Depth,
       isNonEqualPointersWithRecursiveGEP(V2, V1, Q))
     return true;
 
+  Value *A, *B;
+  // PtrToInts are NonEqual if their Ptrs are NonEqual.
+  // Check PtrToInt type matches the pointer size.
+  if (match(V1, m_PtrToInt(m_Value(A))) && match(V2, m_PtrToInt(m_Value(B))) &&
+      Q.DL.getTypeSizeInBits(A->getType()) ==
+          Q.DL.getTypeSizeInBits(V1->getType()))
----------------
nikic wrote:

```suggestion
  if (match(V1, m_PtrToIntSameSize(Q.DL, m_Value(A))) &&
      match(V2, m_PtrToIntSameSize(Q.DL, m_Value(B))))
```

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


More information about the llvm-commits mailing list