[llvm] [InstCombine] Compare `icmp inttoptr, inttoptr` values directly (PR #107012)
Marina Taylor via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 23 08:59:52 PDT 2024
================
@@ -6081,12 +6081,12 @@ Instruction *InstCombinerImpl::foldICmpWithCastOp(ICmpInst &ICmp) {
// Turn icmp (ptrtoint x), (ptrtoint/c) into a compare of the input if the
// integer type is the same size as the pointer type.
- auto CompatibleSizes = [&](Type *SrcTy, Type *DestTy) {
- if (isa<VectorType>(SrcTy)) {
- SrcTy = cast<VectorType>(SrcTy)->getElementType();
- DestTy = cast<VectorType>(DestTy)->getElementType();
+ auto CompatibleSizes = [&](Type *PtrTy, Type *IntTy) {
+ if (isa<VectorType>(PtrTy)) {
+ PtrTy = cast<VectorType>(PtrTy)->getElementType();
+ IntTy = cast<VectorType>(IntTy)->getElementType();
}
- return DL.getPointerTypeSizeInBits(SrcTy) == DestTy->getIntegerBitWidth();
+ return DL.getPointerTypeSizeInBits(PtrTy) == IntTy->getIntegerBitWidth();
----------------
citymarina wrote:
The existing code for `ptrtoint` calls `CompatibleSizes(SrcTy, DestTy)`. The code that I added for `inttoptr` calls with the arguments in the reverse order: `CompatibleSizes(DestTy, SrcTy)`. It felt awkward to pass a `Dest` to a function expecting `Src` and vice versa. I figured that anyway the more important distinction is which is the int and which is the pointer.
https://github.com/llvm/llvm-project/pull/107012
More information about the llvm-commits
mailing list