[LLVMdev] Bug 16257 - fmul of undef ConstantExpr not folded to undef

Oleg Ranevskyy llvm.mail.list at gmail.com
Tue Aug 26 12:20:17 PDT 2014


Hi Duncan,

Thank you for your comment to the bug 16257.

I am new to LLVM, so not all the aspects of LLVM's /"undef"/ seem clear 
to me yet.
I read and understood the examples from the LLVM documentation:
http://llvm.org/docs/LangRef.html#undefined-values

However, those examples do not cover all of the possible contexts where 
/"undef"/ can appear.
E.g., I can't realize why /"fmul undef, undef"/ may not result 
in/"undef"/ whereas /"mul undef, undef"/ is always folded to /"undef"/. 
Seems I am missing something important about floats here.

The same applies to "fdiv".
/"fdiv undef, undef"/ is not folded but /"div %X, undef"/ and /"div 
undef, %X"/ are folded to /"undef"/ (SimplifyFDivInst function in 
lib/Analysis/InstructionSimplify.cpp). Moreover, SimplifyFDivInst does 
not take into account whether signalling of SNaNs can be switched off or 
not - it always folds if one of the operands is /"undef"/.

Another mysterious thing for me is folding of /"mul %X, undef"/.
The result depends on whether %X is odd or even:

  * "undef" if %X is odd or equal to "undef";
  * 0 otherwise.

There is a similar bug 16258 about folding of /"fadd undef, undef"/. 
/"Add" /gets folded to /"undef"/ if one or both its operands are /"undef"/.
Should /"fadd"/ behave differently than integer /"add"/ too?

I've tried to google these questions, scanned StackOverflow, but didn't 
find any good articles / posts answering them. LLVM's /"undef"/ is 
covered quite poorly.

Duncan, do you know of any web resources explaining this in more detail?

Thank you in advance for any help.

Kind regards,
Oleg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140826/92f5639b/attachment.html>


More information about the llvm-dev mailing list