[llvm-dev] Change undef to poison in a few operations

Nuno Lopes via llvm-dev llvm-dev at lists.llvm.org
Tue Jun 6 02:11:10 PDT 2017


Lately we have come to realize how undef makes our life complicated..
Therefore in this email we propose to change the behavior of a few
instruction to yield poison instead of undef in error cases.  This follows
the suggestion of Eli in https://reviews.llvm.org/D33654.

Why is undef so bad?
- I believe it's not possible to make newgvn correct with undef. See for
example the discussion here: https://bugs.llvm.org/show_bug.cgi?id=33165
- A bunch of optimizations are correct with poison but not with undef (see
John's blog posts, my talk at LLVM conf last year, our recent paper on PLDI,

This proposal is not very radical; it's just to change a few error behaviors
to poison and shouldn't have any practical effect for the time being. (so
the change is documentation only)
Later we can continue the work until we have completely removed undef.  Even
if we don't go there, it's generally a good idea to reduce the usage of
undef and replace it with posion whenever possible.

So we propose to change the following from undef to poison:
- insertelement/extractelement (element index out of range)
- shufflevector (undef elements in shuffle mask)
- alloca (allocating zero bytes) ?
- load (load value with different type from written value)
- GEP inrange
- fptrunc/fptoui/fptosi/uitofp/sitofp (overflow) ?
- llvm.ctlz.* and friends (is_zero_undef) ?

Some of these are no brainers, others may need a bit of discussion.

Please let us know if you have thoughts and/or concerns about this.


More information about the llvm-dev mailing list