<br>Let's consider the following piece of C code:  (incomplete and not compilable ;) )<br>  result = initValue;<br>  for(i)<br>  {<br>    ...<br>    if(condition)<br>      result = updatedValue_i;<br>    ...<br>  }<br>
<br>For targets with conditional moves, the result is updated using the following sequence of instructions:<br>regTmp = regFalse;<br>if(condition2) regTmp = regTrue;<br>regResult = regTmp;<br><br>Now, you have 2 cases:<br>
1) either condition2 = condition<br>In this case: regFalse is a phi node between the initial value of result and the current result. It's very likely that regFalse and regResult will be the same hardware register. So the sequence of instructions reduce to just:<br>
if(condition2) regResult = regTrue<br><br>2) either condition2 = !condition<br>In this case, regTrue is a phi node between the initial value of result and the current result. In this case, the sequence of 3 instructions cannot be reduced easily !<br>
<br>So, my question is (finally ;)):<br>Is there a way to introduce some intelligence in the select_cc lowering by reversing the condition if it is likely to generate more efficient code ?<br>I am asking this question because the lowering works on basic blocks with a set of input virtual registers and output virtual registers and all the connections between these 2 set of registers seemed to be "lost" (I don't think we know at the lowering stage that an input register is a phi node between an output register and an initial value...)<br>
<br>  Thank you !<br><br>  Damien<br><br>