[llvm-dev] how LLVM deals with 'undef'

Xiangyang Guo via llvm-dev llvm-dev at lists.llvm.org
Tue Aug 25 12:22:52 PDT 2015

Thanks for reply.

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.



On Tue, Aug 25, 2015 at 3:16 PM, Krzysztof Parzyszek via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> On 8/25/2015 2:09 PM, Xiangyang Guo via llvm-dev wrote:
>> I'm using LLVM-3.8 (current SVN version) to optimize my code. After loop
>> unrolling, I find there is 'undef' in the IR. For example,
>> "/%.lcssa21.unr = phi double [ undef, %.lr.ph9 ], [ %13, %7 ]/". I have
>> two questions:
>> (1) Why this 'undef' is generated?  Because before 'loop unrolling',
>> there is no such 'undef'.
> 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.
> (2) How LLVM backend deals with this 'undef'?
> In general, undef will propagate itself through instructions.  How it will
> deal with this specific one, it's impossible to say without the context.
> -Krzysztof
> --
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted
> by The Linux Foundation
> _______________________________________________
> 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/20150825/dd64a5c4/attachment.html>

More information about the llvm-dev mailing list