[llvm-dev] RFC: Killing undef and spreading poison

Sanjoy Das via llvm-dev llvm-dev at lists.llvm.org
Fri Oct 21 18:55:21 PDT 2016


Hi Krzysztof,

On Fri, Oct 21, 2016 at 4:18 PM, Krzysztof Parzyszek
<kparzysz at codeaurora.org> wrote:
> On 10/20/2016 4:05 PM, Michael Kuperstein wrote:
>>
>> As Sanjoy said, though, it should always be legal to optimize all uses
>> of different "freeze(%x)" values to use the same def - this is
>> equivalent to choosing the same value for all freezes. It's just not
>> necessary to do so.
>
>
> The problem is that once such choice occurs, it takes effect for all
> occurrences of of that value.  For example:
>
>   %x = freeze(provably-poison)
>   %y = freeze(provably-poison)
>   ...
>
>   if (%x == %y) {
>     // lots of code
>   }
>
>   ...
>
>   if (%x < %y) {
>     // lots of code
>   }
>
>   ...
>
>   if (2*%x < %y*(%y+1)) {
>     // even more code
>   }

I mis-parsed your code -- I suppose you wanted to fold _away_ the "//
lots of code" bits, for which you want the inverse of %x->RAUW(%y).
For cases like these, I'd say initially we should go for doing
something simple like replacing %x with 0 and %y with -1.  If we do
end up seeing cases like the above in practice, we can consider
becoming smarter.

This tradeoff isn't very different from how today we fold, say, "sext
i1 undef to i32" to "i32 0", even though it is possible that
downstream uses would have benefited from "remembering" the fact that
"sext i1 undef to i32" can be 0 or -1 depending on the compiler's
whim.

-- Sanjoy


More information about the llvm-dev mailing list