[llvm-dev] undef * 0
Bruce Hoult via llvm-dev
llvm-dev at lists.llvm.org
Fri Sep 2 05:59:49 PDT 2016
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.
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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160902/e72ede19/attachment.html>
More information about the llvm-dev
mailing list