[llvm] [InstCombine] fold `sub(zext(ptrtoint), zext(ptrtoint))` (PR #115369)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 13 16:24:32 PST 2024


================
@@ -2631,6 +2631,21 @@ Instruction *InstCombinerImpl::visitSub(BinaryOperator &I) {
                                                /* IsNUW */ false))
       return replaceInstUsesWith(I, Res);
 
+  if (match(Op0, m_ZExt(m_PtrToInt(m_Value(LHSOp)))) &&
----------------
dtcxzyw wrote:

```suggestion
  if (match(Op0, m_ZExt(m_PtrToIntSameSize(DL, m_Value(LHSOp)))) &&
```
Counterexample: https://alive2.llvm.org/ce/z/BJujTw
Please add a negative test as well.



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


More information about the llvm-commits mailing list