<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Hi Duncan,
<br>
<br>
Thank you for your comment to the bug 16257.
<br>
<br>
I am new to LLVM, so not all the aspects of LLVM's <i>"undef"</i>
seem clear to me yet.
<br>
I read and understood the examples from the LLVM documentation:
<br>
<a class="moz-txt-link-freetext"
href="http://llvm.org/docs/LangRef.html#undefined-values">http://llvm.org/docs/LangRef.html#undefined-values</a>
<br>
<br>
However, those examples do not cover all of the possible contexts
where <i>"undef"</i>
can appear.
<br>
E.g., I can't realize why <i>"fmul undef, undef"</i> may not result
in<i> "undef"</i> whereas <i>"mul
undef, undef"</i> is always folded to <i>"undef"</i>. Seems I am
missing something important about
floats here.
<br>
<br>
The same applies to "fdiv".
<br>
<i>"fdiv undef, undef"</i> is not folded but <i>"div %X, undef"</i>
and <i>"div undef, %X"</i> are
folded to <i>"undef"</i> (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 <i>"undef"</i>.
<br>
<br>
Another mysterious thing for me is folding of <i>"mul %X, undef"</i>.
<br>
The result depends on whether %X is odd or even:
<br>
<ul>
<li>"undef" if %X is odd or equal to "undef";</li>
<li>0 otherwise.
<br>
</li>
</ul>
There is a similar bug 16258 about folding of <i>"fadd undef,
undef"</i>.
<i>"Add" </i>gets folded to <i>"undef"</i> if one or both its
operands are <i>"undef"</i>.<br>
Should <i>"fadd"</i> behave differently than integer <i>"add"</i>
too?
<br>
<br>
I've tried to google these questions, scanned StackOverflow, but
didn't find any
good articles / posts answering them. LLVM's <i>"undef"</i> is
covered quite poorly.
<br>
<br>
Duncan, do you know of any web resources explaining this in more
detail?
<br>
<br>
Thank you in advance for any help.
<br>
<br>
Kind regards,
<br>
Oleg
</body>
</html>