[PATCH] Look through addrspacecasts when turning ptr comparisons into index comparisons.

Matt Arsenault whatmannerofburgeristhis at gmail.com
Wed Feb 19 10:41:58 PST 2014


On Feb 19, 2014, at 10:01 AM, Philip Reames <listmail at philipreames.com> wrote:

> Let me rephrase: I believe your patch would produce invalid IR if the other optimization case is hit.  We'd pick up your unwrapping of address space casts, but not the handling for mismatched widths.
> 
> Specifically, I'm referring to this code:
> if (TD &&
>          GEPsInBounds &&
>          (isa<ConstantExpr>(GEPLHS) || GEPLHS->hasOneUse()) &&
>          (isa<ConstantExpr>(GEPRHS) || GEPRHS->hasOneUse())) {
>        // ((gep Ptr, OFFSET1) cmp (gep Ptr, OFFSET2)  ---> (OFFSET1 cmp OFFSET2)
>        Value *L = EmitGEPOffset(GEPLHS);
>       Value *R = EmitGEPOffset(GEPRHS);
>        return new ICmpInst(ICmpInst::getSignedPredicate(Cond), L, R); // <-- problem here
> }
> 
> Unless there's something I'm missing - feel free to point it out - your change would introduce regressions.
> 
> Philip
> 

I don’t think this part is reachable. This will only be reached if the base pointers of the GEPs are the same, in which case they have the same address space and therefore the same size.

> On 02/18/2014 06:05 PM, Matt Arsenault wrote:
>> On 02/18/2014 05:35 PM, Philip Reames wrote:
>>> There is one other use of EmitGEPOffset feeding into a ICmp in that same function.  Is there a reason it doesn't need similar treatment?
>>> 
>>> Philip
>> I have a few more patches waiting that similarly fix other places, but I'm trying to keep each piece separate when possible.
>> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits





More information about the llvm-commits mailing list