[llvm-dev] [poison] is select-of-select to logic+select allowed?

Sanjay Patel via llvm-dev llvm-dev at lists.llvm.org
Mon May 22 14:27:34 PDT 2017


For background, the reason I was looking at this is because we miss the
transform when the select operands are swapped:

Name: selsel
%s1 = select i1 %cond1, i8 %a, i8 %b
%s2 = select i1 %cond2, i8 %s1, i8 %b
  =>
%notcond1 = xor i1 %cond1, -1
%s1 = select i1 %notcond1, i8 %b, i8 %a
%s2 = select i1 %cond2, i8 %s1, i8 %b

If the transform to and/or is allowed, I'd enhance the matching to account
for this case (if we can invert a condition for free).

I was also wondering about the DAG rules. We don't (need to) consider
poison at that level?



On Mon, May 22, 2017 at 2:50 PM, Matthias Braun <mbraun at apple.com> wrote:

> Are we even at a point in the poison semantics discussion where we can
> reason about it? Is there a canonical description of poison at the moment
> which is in sync with LLVM (and alive)? The LLVM language reference doesn't
> even seem to mention the "poison filtering" effect of select; i.e. when the
> non-poison input of a select is taken no poison comes out of it. While such
> a semantic surely makes sense IMO, it only states that about Phi
> instructions at the moment...
>
> Sorry for not being too helpful here and just answering with more
> questions.
> - I assume matching for `select (i1, i8 freeze, i8 freeze)` like patterns
> would make this correct and as usefull again. But freeze is not part of
> official LLVM AFAIK.
> - If this rule is considered a problem today, then we could probably move
> it to the SelectionDAG level.
>
> - Matthias
>
> On May 22, 2017, at 1:32 PM, Sanjay Patel <spatel at rotateright.com> 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?
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170522/590047b7/attachment-0001.html>


More information about the llvm-dev mailing list