[PATCH] D105088: [InstCombine] Fold IntToPtr/PtrToInt to bitcast
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 6 12:08:56 PDT 2021
efriedma added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:4548
+ auto *I = dyn_cast<PtrToIntInst>(CastOp0->getOperand(0));
+ if (I) {
+ Value *P = I->getOperand(0);
----------------
I think you also need to check the size of p1? If the pointers are in different address spaces, the sizes might not match, so the bitcast will fail to verify. Again, maybe hard to trigger in practice because the ptrtoint destination type gets canonicalized.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:4552
+ Value *NewOp0 = nullptr;
+ NewOp0 = Builder.CreateBitCast(P, Op0Ty);
+ return new ICmpInst(ICmp.getPredicate(), NewOp0, ICmp.getOperand(1));
----------------
Minor nit: `Value *NewOp0 = Builder.CreateBitCast(P, Op0Ty);`
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D105088/new/
https://reviews.llvm.org/D105088
More information about the llvm-commits
mailing list