<div dir="ltr">Is there an earlier check to ensure SSE2 is supported? Just want to make sure we have everything covered.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Mar 10, 2014 at 6:15 PM, Hans Wennborg <span dir="ltr"><<a href="mailto:hans@chromium.org" target="_blank">hans@chromium.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> Actually uploading the new patch...<br>
<div class=""><br>
Hi craig.topper,<br>
<br>
<a href="http://llvm-reviews.chandlerc.com/D3009" target="_blank">http://llvm-reviews.chandlerc.com/D3009</a><br>
<br>
CHANGE SINCE LAST DIFF<br>
</div> <a href="http://llvm-reviews.chandlerc.com/D3009?vs=7725&id=7728#toc" target="_blank">http://llvm-reviews.chandlerc.com/D3009?vs=7725&id=7728#toc</a><br>
<br>
Files:<br>
lib/Target/X86/X86ISelLowering.cpp<br>
<div class=""> test/CodeGen/X86/isint.ll<br>
<br>
Index: lib/Target/X86/X86ISelLowering.cpp<br>
===================================================================<br>
--- lib/Target/X86/X86ISelLowering.cpp<br>
+++ lib/Target/X86/X86ISelLowering.cpp<br>
</div>@@ -18056,9 +18056,25 @@<br>
<div class=""> SDValue OnesOrZeroesF = DAG.getNode(X86ISD::FSETCC, DL,<br>
CMP00.getValueType(), CMP00, CMP01,<br>
DAG.getConstant(x86cc, MVT::i8));<br>
- MVT IntVT = (is64BitFP ? MVT::i64 : MVT::i32);<br>
- SDValue OnesOrZeroesI = DAG.getNode(ISD::BITCAST, DL, IntVT,<br>
- OnesOrZeroesF);<br>
+<br>
</div>+ MVT IntVT = is64BitFP ? MVT::i64 : MVT::i32;<br>
<div class="">+<br>
+ if (is64BitFP && !Subtarget->is64Bit()) {<br>
</div><div class="">+ // On a 32-bit target, we cannot bitcast the 64-bit float to a<br>
</div>+ // 64-bit integer, since that's not a legal type. Since<br>
+ // OnesOrZeroesF is all ones of all zeroes, we don't need all the<br>
+ // bits, but can do this little dance to extract the lowest 32 bits<br>
+ // and work with those going forward.<br>
+ SDValue Vector64 = DAG.getNode(ISD::SCALAR_TO_VECTOR, DL, MVT::v2f64,<br>
+ OnesOrZeroesF);<br>
+ SDValue Vector32 = DAG.getNode(ISD::BITCAST, DL, MVT::v4f32,<br>
+ Vector64);<br>
+ OnesOrZeroesF = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, MVT::f32,<br>
+ Vector32, DAG.getIntPtrConstant(0));<br>
<div class="">+ IntVT = MVT::i32;<br>
+ }<br>
</div>+<br>
+ SDValue OnesOrZeroesI = DAG.getNode(ISD::BITCAST, DL, IntVT, OnesOrZeroesF);<br>
<div class=""> SDValue ANDed = DAG.getNode(ISD::AND, DL, IntVT, OnesOrZeroesI,<br>
DAG.getConstant(1, IntVT));<br>
SDValue OneBitOfTruth = DAG.getNode(ISD::TRUNCATE, DL, MVT::i8, ANDed);<br>
</div><div class="">Index: test/CodeGen/X86/isint.ll<br>
===================================================================<br>
--- test/CodeGen/X86/isint.ll<br>
+++ test/CodeGen/X86/isint.ll<br>
</div>@@ -1,22 +1,46 @@<br>
<div class="">-; RUN: llc < %s -march=x86 -mattr=+sse2 -mcpu=penryn| FileCheck %s<br>
+; RUN: llc < %s -mtriple=x86_64-pc-unknown -mattr=+sse2 -mcpu=penryn | FileCheck %s<br>
+; RUN: llc < %s -mtriple=i686-pc-unknown -mattr=+sse2 -mcpu=penryn | FileCheck %s<br>
+<br>
+; PR19059<br>
+; RUN: llc < %s -mtriple=i686-pc-unknown -mattr=+sse2 -mcpu=penryn | FileCheck -check-prefix=CHECK32 %s<br>
<br>
define i32 @isint_return(double %d) nounwind {<br>
</div><div class="">+; CHECK-LABEL: isint_return:<br>
; CHECK-NOT: xor<br>
; CHECK: cvt<br>
%i = fptosi double %d to i32<br>
; CHECK-NEXT: cvt<br>
</div><div class=""> %e = sitofp i32 %i to double<br>
; CHECK: cmpeqsd<br>
%c = fcmp oeq double %d, %e<br>
+; CHECK32-NOT: movd {{.*}}, %r{{.*}}<br>
+; CHECK32-NOT: andq<br>
</div><div class="">+; CHECK-NEXT: movd<br>
+; CHECK-NEXT: andl<br>
+ %z = zext i1 %c to i32<br>
+ ret i32 %z<br>
+}<br>
+<br>
+define i32 @isint_float_return(float %f) nounwind {<br>
+; CHECK-LABEL: isint_float_return:<br>
+; CHECK-NOT: xor<br>
+; CHECK: cvt<br>
+ %i = fptosi float %f to i32<br>
+; CHECK-NEXT: cvt<br>
+ %g = sitofp i32 %i to float<br>
+; CHECK: cmpeqss<br>
+ %c = fcmp oeq float %f, %g<br>
</div>+; CHECK-NOT: movd {{.*}}, %r{{.*}}<br>
<div class="im HOEnZb"> ; CHECK-NEXT: movd<br>
-; CHECK-NEXT: andq<br>
+; CHECK-NEXT: andl<br>
%z = zext i1 %c to i32<br>
ret i32 %z<br>
}<br>
<br>
</div><div class="HOEnZb"><div class="h5"> declare void @foo()<br>
<br>
define void @isint_branch(double %d) nounwind {<br>
+; CHECK-LABEL: isint_branch:<br>
; CHECK: cvt<br>
%i = fptosi double %d to i32<br>
; CHECK-NEXT: cvt<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>~Craig
</div>