I haven't run the full test suite yet, but r160036 seems to have fixed at least the failure I was seeing.<br><br>setcc's type was i32 when the transformation was being done, as you suspected. <br>Test case was committed in 160067.<br>
<br>Thank you for the clarification and fix.<br><br><div class="gmail_quote">On Tue, Jul 10, 2012 at 11:39 PM, Owen Anderson <span dir="ltr"><<a href="mailto:resistor@mac.com" target="_blank">resistor@mac.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word">Akira,<div><br></div><div>I've speculatively fixed this in r160036.  If this fixes the issue for you, would you mind preparing a testcase for inclusion in the regression tests?</div>
<span class="HOEnZb"><font color="#888888"><div><br></div><div>--Owen</div></font></span><div><div class="h5"><div><br><div><div>On Jul 10, 2012, at 8:28 PM, Owen Anderson wrote:</div><br><blockquote type="cite"><div style="word-wrap:break-word">
Akira,<div><br></div><div>Pete's reasoning is what I was going to respond with.  However, on looking back at my patch, perhaps I should be checking that the SETCC has type MVT::i1?  Can you check if the code you're seeing the problem with has a SETCC -> SINT_TO_FP where the SETCC has type other than MVT::i1?</div>
<div><br></div><div>--Owen</div><div><br><div><div>On Jul 10, 2012, at 7:12 PM, Peter Cooper wrote:</div><br><blockquote type="cite"><div style="word-wrap:break-word">Hi Akira<div><br></div><div>This is because an i1 value of 1 is all ones which is actually a -1 if you think about it as signed and then convert using sint.  A uint conversion would give a 1.0 value.</div>
<div><br></div><div>Pete<br><div><div>On Jul 10, 2012, at 5:36 PM, Akira Hatanaka <<a href="mailto:ahatanak@gmail.com" target="_blank">ahatanak@gmail.com</a>> wrote:</div><br><blockquote type="cite">Owen,<br><br>Could you explain why "-1.0" is selected instead of "1.0" here?<br>
<br>// fold (sint_to_fp (setcc x, y, cc)) -> (select_cc x, y, -1.0, 0.0,,
 cc)<br><br>An expression in my test program is evaluating to -3.2 instead of the expected value -1.2. I haven't confirmed this yet, but it looks like it would be correct if "1.0" were selected.<br><br>Does this have anything to do with setBooleanContents?<br>

For mips this is set to "ZeroOrOneBooleanContent".<br><br><div class="gmail_quote">On Mon, Jul 9, 2012 at 1:31 PM, Owen Anderson <span dir="ltr"><<a href="mailto:resistor@mac.com" target="_blank">resistor@mac.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Author: resistor<br>
Date: Mon Jul  9 15:31:12 2012<br>
New Revision: 159957<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=159957&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=159957&view=rev</a><br>
Log:<br>
Teach the DAG combiner to turn sitofp/uitofp from i1 into a conditional move, since there are only two possible values.<br>
Previously, this would become an integer extension operation, followed by a real integer->float conversion.<br>
<br>
Modified:<br>
    llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp<br>
    llvm/trunk/test/CodeGen/ARM/select.ll<br>
<br>
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=159957&r1=159956&r2=159957&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=159957&r1=159956&r2=159957&view=diff</a><br>


==============================================================================<br>
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Mon Jul  9 15:31:12 2012<br>
@@ -5974,6 +5974,30 @@<br>
       return DAG.getNode(ISD::UINT_TO_FP, N->getDebugLoc(), VT, N0);<br>
   }<br>
<br>
+  // fold (sint_to_fp (setcc x, y, cc)) -> (select_cc x, y, -1.0, 0.0,, cc)<br>
+  if (N0.getOpcode() == ISD::SETCC && !VT.isVector() &&<br>
+      (!LegalOperations ||<br>
+       TLI.isOperationLegalOrCustom(llvm::ISD::ConstantFP, VT))) {<br>
+    SDValue Ops[] =<br>
+      { N0.getOperand(0), N0.getOperand(1),<br>
+        DAG.getConstantFP(-1.0, VT) , DAG.getConstantFP(0.0, VT),<br>
+        N0.getOperand(2) };<br>
+    return DAG.getNode(ISD::SELECT_CC, N->getDebugLoc(), VT, Ops, 5);<br>
+  }<br>
+<br>
+  // fold (sint_to_fp (zext (setcc x, y, cc))) -><br>
+  //      (select_cc x, y, 1.0, 0.0,, cc)<br>
+  if (N0.getOpcode() == ISD::ZERO_EXTEND &&<br>
+      N0.getOperand(0).getOpcode() == ISD::SETCC &&!VT.isVector() &&<br>
+      (!LegalOperations ||<br>
+       TLI.isOperationLegalOrCustom(llvm::ISD::ConstantFP, VT))) {<br>
+    SDValue Ops[] =<br>
+      { N0.getOperand(0).getOperand(0), N0.getOperand(0).getOperand(1),<br>
+        DAG.getConstantFP(1.0, VT) , DAG.getConstantFP(0.0, VT),<br>
+        N0.getOperand(0).getOperand(2) };<br>
+    return DAG.getNode(ISD::SELECT_CC, N->getDebugLoc(), VT, Ops, 5);<br>
+  }<br>
+<br>
   return SDValue();<br>
 }<br>
<br>
@@ -5999,6 +6023,18 @@<br>
       return DAG.getNode(ISD::SINT_TO_FP, N->getDebugLoc(), VT, N0);<br>
   }<br>
<br>
+  // fold (uint_to_fp (setcc x, y, cc)) -> (select_cc x, y, -1.0, 0.0,, cc)<br>
+  if (N0.getOpcode() == ISD::SETCC && !VT.isVector() &&<br>
+      (!LegalOperations ||<br>
+       TLI.isOperationLegalOrCustom(llvm::ISD::ConstantFP, VT))) {<br>
+    SDValue Ops[] =<br>
+      { N0.getOperand(0), N0.getOperand(1),<br>
+        DAG.getConstantFP(1.0, VT),  DAG.getConstantFP(0.0, VT),<br>
+        N0.getOperand(2) };<br>
+    return DAG.getNode(ISD::SELECT_CC, N->getDebugLoc(), VT, Ops, 5);<br>
+  }<br>
+<br>
+<br>
   return SDValue();<br>
 }<br>
<br>
<br>
Modified: llvm/trunk/test/CodeGen/ARM/select.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/select.ll?rev=159957&r1=159956&r2=159957&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/select.ll?rev=159957&r1=159956&r2=159957&view=diff</a><br>


==============================================================================<br>
--- llvm/trunk/test/CodeGen/ARM/select.ll (original)<br>
+++ llvm/trunk/test/CodeGen/ARM/select.ll Mon Jul  9 15:31:12 2012<br>
@@ -113,3 +113,29 @@<br>
   call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, [2 x i32], i32, float)*)(i8* undef, i8* undef, [2 x i32] %tmp493, i32 0, float 1.000000e+00) optsize<br>
   ret void<br>
 }<br>
+<br>
+; CHECK: f10<br>
+define float @f10(i32 %a, i32 %b) nounwind uwtable readnone ssp {<br>
+; CHECK-NOT: floatsisf<br>
+  %1 = icmp eq i32 %a, %b<br>
+  %2 = zext i1 %1 to i32<br>
+  %3 = sitofp i32 %2 to float<br>
+  ret float %3<br>
+}<br>
+<br>
+; CHECK: f11<br>
+define float @f11(i32 %a, i32 %b) nounwind uwtable readnone ssp {<br>
+; CHECK-NOT: floatsisf<br>
+  %1 = icmp eq i32 %a, %b<br>
+  %2 = sitofp i1 %1 to float<br>
+  ret float %2<br>
+}<br>
+<br>
+; CHECK: f12<br>
+define float @f12(i32 %a, i32 %b) nounwind uwtable readnone ssp {<br>
+; CHECK-NOT: floatunsisf<br>
+  %1 = icmp eq i32 %a, %b<br>
+  %2 = uitofp i1 %1 to float<br>
+  ret float %2<br>
+}<br>
+<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br>
_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div></blockquote></div><br></div></div>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br></blockquote></div><br></div></div></div></div></blockquote></div><br>