[llvm-commits] [llvm] r151467 - in /llvm/trunk: lib/Analysis/InstructionSimplify.cpp test/Transforms/InstCombine/icmp.ll test/Transforms/InstSimplify/compare.ll

Eli Friedman eli.friedman at gmail.com
Wed Feb 29 00:06:20 PST 2012


On Tue, Feb 28, 2012 at 11:49 PM, Nick Lewycky <nicholas at mxc.ca> wrote:
> Eli Friedman wrote:
>>
>> On Sat, Feb 25, 2012 at 6:09 PM, Nick Lewycky<nicholas at mxc.ca>  wrote:
>>>
>>> Author: nicholas
>>> Date: Sat Feb 25 20:09:49 2012
>>> New Revision: 151467
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=151467&view=rev
>>> Log:
>>> Reinstate the optimization from r151449 with a fix to not turn 'gep %x'
>>> into
>>> 'gep null' when the icmp predicate is unsigned (or is signed without
>>> inbounds).
>>>
>>> Modified:
>>>    llvm/trunk/lib/Analysis/InstructionSimplify.cpp
>>>    llvm/trunk/test/Transforms/InstCombine/icmp.ll
>>>    llvm/trunk/test/Transforms/InstSimplify/compare.ll
>>
>>
>> This change is causing an execution failure in the gcc testsuite on
>> gcc.c-torture/execute/frame-address.c .  Please take a look.
>
>
> int check_fa_work (const char *c, const char *f)
> {
>  const char d = 0;
>
>  if (c >= &d)
>    return c >= f && f >= &d;
>  else
>    return c <= f && f <= &d;
> }
>
> With this patch we decide that the incoming arguments can't legitimately be
> compared with the local variable, taking advantage of the undefined
> behaviour. This function is optimized into "ret i32 0".

The LangRef rules for icmp seem to state that the result is always
well-defined... if we're following different rules, please update it.

-Eli




More information about the llvm-commits mailing list