[PATCH] D15146: [InstCombine] Look through PHIs, GEPs, IntToPtrs and PtrToInts to expose more constants when comparing GEPs
silviu.baranga@arm.com via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 11 09:03:09 PST 2015
sbaranga added inline comments.
================
Comment at: lib/Transforms/InstCombine/InstCombineCompares.cpp:905
@@ +904,3 @@
+ // OFFSET1 cmp OFFSET2
+ Value *NewRHS = RewriteGEPAsOffset(RHS, PtrBase, DL, Nodes);
+ return new ICmpInst(ICmpInst::getSignedPredicate(Cond), Index, NewRHS);
----------------
hfinkel wrote:
> Still don't find this clear. It seems to me that:
>
> std::tie(PtrBase, Index) = GetAsConstantIndexedAddress(GEPLHS, DL);
>
> returns PtrBase and Index such that GEP(PtrBase, Index) == GEPLHS. And then:
>
> RewriteGEPAsOffset(RHS, PtrBase)
>
> returns GEP(PtrBase, Something) == RHS. And then we compare:
>
> Index icmp GEP(PtrBase, Something)
>
> which must be wrong. What am I missing?
>
RewriteGEPAsOffset returns the offset, not the GEP.
http://reviews.llvm.org/D15146
More information about the llvm-commits
mailing list