[llvm-dev] undef * 0

Manuel Jacob via llvm-dev llvm-dev at lists.llvm.org
Fri Sep 2 05:59:14 PDT 2016


On 2016-09-02 14:33, Soham Chakraborty via llvm-dev 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?

Yes, this is correct.  The optimizer can insert any value for 'undef', 
so this transformation is correct for multiple reasons.

(a) X * 0 = 0 is correct for any X because of arithmethic rules, so you 
don't even need 'undef' for X.
(b) undef * X = 0 is correct as well by choosing 0 for undef.  Your 
example is a special case of this by setting X = 0.

-Manuel

> Best Regards,
> soham
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


More information about the llvm-dev mailing list