<div dir="ltr"><div>For background, the reason I was looking at this is because we miss the transform when the select operands are swapped:<br><br>Name: selsel<br>%s1 = select i1 %cond1, i8 %a, i8 %b<br>%s2 = select i1 %cond2, i8 %s1, i8 %b<br>  =><br>%notcond1 = xor i1 %cond1, -1<br>%s1 = select i1 %notcond1, i8 %b, i8 %a<br>%s2 = select i1 %cond2, i8 %s1, i8 %b<br><br></div>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).<br><div><br></div><div>I was also wondering about the DAG rules. We don't (need to) consider poison at that level?<br></div><div><br><br><div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 22, 2017 at 2:50 PM, Matthias Braun <span dir="ltr"><<a href="mailto:mbraun@apple.com" target="_blank">mbraun@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;"><div>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...</div><div><br></div><div>Sorry for not being too helpful here and just answering with more questions.</div><div>- 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.</div><div>- If this rule is considered a problem today, then we could probably move it to the SelectionDAG level.</div><span class="gmail-HOEnZb"><font color="#888888"><div><br></div><div>- Matthias</div></font></span><div><div class="gmail-h5"><div><br></div><div><blockquote type="cite"><div>On May 22, 2017, at 1:32 PM, Sanjay Patel <<a href="mailto:spatel@rotateright.com" target="_blank">spatel@rotateright.com</a>> wrote:</div><br class="gmail-m_6082426889438072770Apple-interchange-newline"><div><div dir="ltr"><div>Some InstCombine transforms for select-of-select were added here:<br><a href="https://reviews.llvm.org/rL228409" target="_blank">https://reviews.llvm.org/<wbr>rL228409</a><br><br>But Alive says this is more poisonous:<br><br>Name: selsel<br>%s1 = select i1 %cond1, i8 C1, i8 C2<br>%s2 = select i1 %cond2, i8 %s1, i8 C2<br>  =><br>%andcond = and i1 %cond1, %cond2<br>%s2 = select i1 %andcond, i8 C1, i8 C2<br><br><a href="http://rise4fun.com/Alive/JT6" target="_blank">http://rise4fun.com/Alive/JT6</a><br><br></div>Are those transforms legal?<br><div><div><div><br></div></div></div></div>
</div></blockquote></div><br></div></div></div></blockquote></div><br></div></div></div></div>