[llvm-dev] undef * 0

soham chakraborty via llvm-dev llvm-dev at lists.llvm.org
Fri Sep 2 07:12:00 PDT 2016


@Manuel Jacob and Bruce Hoult

Thanks a lot for your answer.

Best Regards,
soham

On Fri, Sep 2, 2016 at 3:12 PM, Manuel Jacob <me at manueljacob.de> wrote:

> On 2016-09-02 14:59, Bruce Hoult via llvm-dev wrote:
>
>> llvm thinks so.
>>
>> You can easily see what it actually does in cases like this.
>>
>> echo 'int foo(int a){return 23 * a;}' >undeftimes.c
>> clang -S -emit-llvm undeftimes.c
>> vi undeftimes.ll # change the 23 to undef
>> llc undeftimes.ll
>> less undeftimes.s
>>
>> Personally, I find ARM (or other RISC) code far easier to follow than x86,
>> so I generally add a "-march=arm" to the llc step if I'm on an x86 host,
>> but that's personal preference.
>>
>
> Or even `opt -S -O3 undeftimes.ll` to see what the (full) optimizer
> pipeline does instead of just what llc does (llc only does a limited set of
> transformations).
>
>
> foo:
>> push {r0}
>> mov r0, #0
>> add sp, sp, #4
>> mov pc, lr
>>
>> Yep .. it just returns 0.
>>
>> Idle question, if anyone is reading still ... how do you get llc to do -Os
>> or -Oz? The docs say the argument must be an integer, and anything other
>> than 0..3 is rejected. (in fact .. bug report ... 10 thru 39 are also
>> silently accepted as are 100 thru 399 etc)
>>
>> On Fri, Sep 2, 2016 at 3:33 PM, Soham Chakraborty via llvm-dev <
>> llvm-dev at lists.llvm.org> wrote:
>>
>> What is the value of undef * 0 in LLVM?
>>>
>>> According to its definition in  the LLVM IR reference;
>>>
>>> "The string ‘undef‘ can be used anywhere a constant is expected..."
>>>
>>> Am I correct to say that undef * 0 = 0 following this definition?
>>>
>>> Best Regards,
>>> soham
>>> _______________________________________________
>>> LLVM Developers mailing list
>>> llvm-dev at lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>>>
>>>
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160902/1f1b4fbd/attachment.html>


More information about the llvm-dev mailing list