<div dir="ltr">On Tue, Aug 13, 2013 at 3:59 PM, Jim Grosbach <span dir="ltr"><<a href="mailto:grosbach@apple.com" target="_blank">grosbach@apple.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><div><div class="h5"><div>On Aug 13, 2013, at 3:33 PM, Eli Friedman <<a href="mailto:eli.friedman@gmail.com" target="_blank">eli.friedman@gmail.com</a>> wrote:</div>
<br><blockquote type="cite"><div dir="ltr">On Tue, Aug 13, 2013 at 3:09 PM, Jim Grosbach <span dir="ltr"><<a href="mailto:grosbach@apple.com" target="_blank">grosbach@apple.com</a>></span> wrote:<br><div class="gmail_extra">
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><div><div><div>On Aug 13, 2013, at 2:39 PM, Eli Friedman <<a href="mailto:eli.friedman@gmail.com" target="_blank">eli.friedman@gmail.com</a>> wrote:</div>

<br><blockquote type="cite"><div dir="ltr">On Tue, Aug 13, 2013 at 2:30 PM, Jim Grosbach <span dir="ltr"><<a href="mailto:grosbach@apple.com" target="_blank">grosbach@apple.com</a>></span> wrote:<br><div class="gmail_extra">

<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: grosbach<br>
Date: Tue Aug 13 16:30:58 2013<br>
New Revision: 188315<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=188315&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=188315&view=rev</a><br>
Log:<br>
DAG: Combine (and (setne X, 0), (setne X, -1)) -> (setuge (add X, 1), 2)<br>
<br>
A common idiom is to use zero and all-ones as sentinal values and to<br>
check for both in a single conditional ("x != 0 && x != (unsigned)-1").<br>
That generates code, for i32, like:<br>
  testl %edi, %edi<br>
  setne %al<br>
  cmpl  $-1, %edi<br>
  setne %cl<br>
  andb  %al, %cl<br>
<br>
With this transform, we generate the simpler:<br>
  incl  %edi<br>
  cmpl  $1, %edi<br>
  seta  %al<br>
<br>
Similar improvements for other integer sizes and on other platforms. In<br>
general, combining the two setcc instructions into one is better.<br>
<br>
<a>rdar://14689217</a><br><br></blockquote><div><br></div><div>We already have code in InstCombiner::FoldAndOfICmps to handle this sort of thing; it looks like it isn't catching this particular case for some reason, though.</div>


<div><br></div></div></div></div></blockquote><div><br></div></div></div><div>There’s already a bunch of similar checks in the DAGCombiner, too. I mainly put it there to that we’ll be able to catch more complicate cases that simplify to this one from other DAG transformations, that are exposed from target lowerings, etc..</div>

</div></div></blockquote><div><br></div><div>I'm not convinced it will actually show up from lowering in practice. </div></div></div></div></blockquote><div><br></div></div></div><div>I’m not convinced either way, really. Simply a mild motivation in one direction over the other. *shrug*</div>
<div><br></div><div>That said, then why do we have any of the transformations we do for setcc in DAGCombine? The same sort of arguments can be made equally strongly for them, yes?</div></div></div></blockquote><div><br></div>
<div>Well, some of the transformations show up after legalization from simple transformations like splitting an equality comparison.</div><div><br></div><div>-Eli</div></div></div></div>