<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Apr 24, 2013, at 11:28 AM, Shuxin Yang <<a href="mailto:shuxin.llvm@gmail.com">shuxin.llvm@gmail.com</a>> wrote:</div><blockquote type="cite"><div bgcolor="#FFFFFF" text="#000000"><blockquote cite="mid:AE19DACE-53C4-40CD-9FFD-D6433536D080@apple.com" 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>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><br><blockquote type="cite"><div bgcolor="#FFFFFF" text="#000000"><blockquote cite="mid:AE19DACE-53C4-40CD-9FFD-D6433536D080@apple.com" type="cite"><div><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align:
start; text-indent: 0px; text-transform: none; white-space:
normal; widows: auto; word-spacing: 0px;
-webkit-text-stroke-width: 0px;">That said, we should have a
reason to if-convert before lowering other than optimizing
for a machine's cpu pipeline.<br>
<br>
Are we all convinced that if-converting a single store is
the proper canonical form?<br>
</div>
</blockquote>
<div><br>
</div>
I am, at least in this specific benchmark's case. You *can't*
legally do the if conversion if you are introducing a memory
access that otherwise would not have done. Doing this can have
lots of semantic effects. In order for this to be *legal* at
all (ignoring profitability) you have to prove that a subsequent
store is happening to the memory location.</div>
<div><br>
</div>
<div>In this case, the *profitability* comes down to being able to
obviously, locally, eliminate a load from the address. It's
true that GVN/PRE can eliminate part of the load in principle,
but in practice this doesn't happen.<br>
</div>
</blockquote>
GVN get rid of all the loads for the cases this if-cvt is trying to
catch. <br>
</div>
</blockquote></div><br><div>… but much much later in the pipeline. My point is that the transformation is still locally profitable.</div><div><br></div><div>-Chris</div></body></html>