[PATCH] Fix wrong loop exit check created by LinearFunctionTestReplace

Andrew Trick atrick at apple.com
Wed Oct 23 22:05:16 PDT 2013


On Oct 23, 2013, at 8:50 PM, Juergen Ributzka <juergen at apple.com> wrote:

> Hi Andy,
> 
> I moved the test case to the appropriate location and reduced it as you suggested.
> Please see the attached updated patch.

LGTM.
-Andy

> 
> Thanks
> 
> Cheers,
> Juergen
> 
> <lftr.patch>
> On Oct 23, 2013, at 5:19 PM, Andrew Trick <atrick at apple.com> wrote:
> 
>> 
>> On Oct 23, 2013, at 1:29 PM, Juergen Ributzka <juergen at apple.com> wrote:
>> 
>>> Hi @ll,
>>> 
>>> the following reduced test case is currently miscompiled by llvm:
>>> 
>>> uint8_t data[240];
>>> for(uint8_t i = 0; i < 240; ++i)
>>> 	*data++ = *p++;
>>> 
>>> LinearFunctionTestReplace replaces the induction variable “i" with the pointer “data" and calculates a new bound check for the loop based on the base pointer and the loop trip count. genLoopCount treats the loop trip count as a signed variable and this leads to a incorrect GEP offset calculation (-16 instead of 240). This small fix just zero extends the loop trip count value instead of sign extending it. The loop trip count should be treated as an unsigned value and FindLoopCounter guarantees that we only have to deal with loops with positive unit strides of one.
>>> 
>>> Cheers,
>>> Juergen
>> 
>> Great. Thanks for the fix. For the test case, please dump the IR just before indvars and check the IR generated by the broken pass.
>> 
>> e.g.
>> In test/Transforms/IndvarSimplify/lftr-zext.ll
>> 
>> ; RUN: opt < %s -indvars -S | FileCheck %s
>> ...
> 





More information about the llvm-commits mailing list