[llvm] [InstCombine] Fold icmp ptrtoaddr x, ptrtoaddr y -> icmp x, y (PR #211991)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 25 00:09:56 PDT 2026


================
@@ -6555,13 +6555,18 @@ Instruction *InstCombinerImpl::foldICmpWithCastOp(ICmpInst &ICmp) {
     }
     return DL.getPointerTypeSizeInBits(PtrTy) == IntTy->getIntegerBitWidth();
   };
-  if (CastOp0->getOpcode() == Instruction::PtrToInt &&
+  if (isa<PtrToIntInst, PtrToAddrInst>(CastOp0) &&
       CompatibleSizes(SrcTy, DestTy)) {
----------------
dtcxzyw wrote:

For `icmp ptrtoaddr x, ptrtoaddr y`, we don't need the width check. Otherwise, we always reject the fold with pointer types that contain non-address bits.


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


More information about the llvm-commits mailing list