[llvm-dev] [poison] is select-of-select to logic+select allowed?
John Regehr via llvm-dev
llvm-dev at lists.llvm.org
Mon May 22 13:45:11 PDT 2017
Nuno and I have been looking through the results of experiments like the
one reported here:
https://blog.regehr.org/archives/1510
Indeed there are some select-related transformations in LLVM that are
illegal in terms of Alive's semantics. As far as we know, they cannot be
made legal (by adjusting the semantics of instructions) without breaking
a bunch of other optimizations.
The optimizations currently in LLVM are not only inconsistent but they
can lead to end-to-end miscompilations. Sorting this out is going to
require (1) figuring out what select means WRT poison/undef and (2)
backing out some optimizations. This is going to be slightly painful but
it is the only way forward.
John
On 5/22/17 2:32 PM, Sanjay Patel wrote:
> Some InstCombine transforms for select-of-select were added here:
> https://reviews.llvm.org/rL228409
>
> But Alive says this is more poisonous:
>
> Name: selsel
> %s1 = select i1 %cond1, i8 C1, i8 C2
> %s2 = select i1 %cond2, i8 %s1, i8 C2
> =>
> %andcond = and i1 %cond1, %cond2
> %s2 = select i1 %andcond, i8 C1, i8 C2
>
> http://rise4fun.com/Alive/JT6
>
> Are those transforms legal?
>
More information about the llvm-dev
mailing list