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

Philip Reames listmail at philipreames.com
Wed Feb 19 10:01:35 PST 2014


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

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.
>




More information about the llvm-commits mailing list