<div dir="ltr"><div class="gmail_extra" style>I generally agree with Chris's position in the here-and-now FWIW. We should continue to balance the IR-level if-conversion for canonicalization against the down sides.</div>
<div class="gmail_extra" style><br></div><div class="gmail_extra" style>However, I wanted to point out that increasingly I have a different long-term hope for this type of canonicalization that has been heavily influenced by Evan, Andy, Jakob, and Dan Gohman's problems with doing canonicalizations like this at the IR level:</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">On Wed, Apr 24, 2013 at 7:37 PM, Chris Lattner <span dir="ltr"><<a href="mailto:clattner@apple.com" target="_blank" class="cremed">clattner@apple.com</a>></span> wrote:<br>
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><div>On Apr 24, 2013, at 11:28 AM, Shuxin Yang <<a href="mailto:shuxin.llvm@gmail.com" target="_blank" class="cremed">shuxin.llvm@gmail.com</a>> wrote:</div>
<blockquote type="cite"><div bgcolor="#FFFFFF" text="#000000"><blockquote type="cite"><div><div><br>
        </div>
        <div>Because this is a canonicalization of this sort, it seems
          clearly good to do on IR, and early.  Doing something like
          this at the codegen level specifically for micro-architectural
          reasons could also make sense, but I don't see that
          eliminating the usefulness of doing it early as well.</div>
      </div>
    </blockquote>
    Introducing a "select" at IR level dose not necessarily means
    CodeGen convert the "select" with predicated instruction like cmov.<br>
    cmov is not necessary inexpensive, for example, on Pentium 4, the
    latency of cmov is about 10+ cycle. <br></div></blockquote><div><br></div></div><div>Yes, I truly understand that.  My point is that it is still a canonicalization: depending on how the user wrote the code is silly for the opposite reason: if they wrote code with ?: or max on pentium 4, codegen should convert it to an "if" if the branch is biased.</div>
</blockquote></div><div class="gmail_extra"><br></div>I feel like we need a better strategy long-term. Increasingly, I'm of the opinion that as we move away from the SelectionDAG's basic block limitations, we should also move away from canonicalizing to the if-converted code. These days I would rather see us add utilities to LLVM to look across basic blocks which form PHI-only CFGs as-if they were straight line code, and to have the canonical form of predicated values be PHI-only CFGs. This has a nice advantage of simplifying the IR model, and being strictly more general than selects. However, it *requires* that we don't have a basic-block granularity hard limitation in passes, and that's just not the world we live in currently. Maybe eventually.</div>
</div>