<div dir="ltr">Just because you don't see an 'undef' doesn't mean there isn't any undefined behaviour already present in your code. <div>eg, bit shifting too far, loading from uninitialised memory, divide by zero, calling a function with the wrong ABI...</div><div><div><br></div><div>There are plenty of optimizations that will detect this undefined behaviour and replace it with 'undef'. <div><br><div>Without seeing your code, we can't tell you exactly why this is happening.</div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 26, 2015 at 4:52 AM, Xiangyang Guo via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks for reply.<div><br></div><div>First, I use Clang to compile my source code without any optimization so that I get one .bc file, in which there is no 'undef' showing up. Then, I use opt to optimize the IR. So I assume things are correct and the 'undef' is introduced to satisfy the syntax of phi node, as you mentioned. But I really don't want this 'undef' in IR. Do you have any idea to get rid of 'undef'? Thanks a lot.</div><div><br></div><div>Regards,</div><div><br></div><div>Xiangyang</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 25, 2015 at 3:16 PM, Krzysztof Parzyszek via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On 8/25/2015 2:09 PM, Xiangyang Guo via llvm-dev wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>
<br>
I'm using LLVM-3.8 (current SVN version) to optimize my code. After loop<br>
unrolling, I find there is 'undef' in the IR. For example,<br></span>
"/%.lcssa21.unr = phi double [ undef, %.lr.ph9 ], [ %13, %7 ]/". I have<span><br>
two questions:<br>
<br>
(1) Why this 'undef' is generated?  Because before 'loop unrolling',<br>
there is no such 'undef'.<br>
</span></blockquote>
<br>
Most likely to satisfy the syntax of a phi node.  If everything is correct, that value will never be used.  If things weren't exactly correct, this may be a result of a load from an uninitialized memory, or something like that.<span><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
(2) How LLVM backend deals with this 'undef'?<br>
</blockquote>
<br></span>
In general, undef will propagate itself through instructions.  How it will deal with this specific one, it's impossible to say without the context.<span><font color="#888888"><br>
<br>
-Krzysztof<br>
<br>
-- <br>
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</font></span></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>