[PATCH] D23808: [X86][SSE] Add lowering to cvttpd2dq/cvttps2dq for sitofp v2f64/2f32 to 2i32

Elena Demikhovsky via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 4 12:48:24 PDT 2016

delena added inline comments.

Comment at: lib/Target/X86/X86ISelLowering.cpp:22229
@@ -22227,1 +22228,3 @@
+    if (IsSigned && N->getValueType(0) == MVT::v2i32) {
+      assert(Subtarget.hasSSE2() && "Requires at least SSE2!");
RKSimon wrote:
> As the result type is the illegal v2i32 type we need to use ReplaceNodeResults - we can't just go direct to Lower_FP_TO_SINT as type legalization will get in the way.
If you specify 
setOperationAction(ISD::FP_TO_SINT,         MVT::v2f32, Custom) - specify source type, because type legalizer looks at it first.
it takes you directly from type legalizer to LowerFP_TO_SINT().

Please look at LowerSINT_TO_FP(), we do the same there.

Additionally, you do
setOperationAction(ISD::FP_TO_SINT,         MVT::v2i32, Custom) - it will call LowerFP_TO_SINT() for v2f64 -> v2i32

Comment at: lib/Target/X86/X86ISelLowering.cpp:22234
@@ +22233,3 @@
+        SDValue Idx = DAG.getIntPtrConstant(0, dl);
+        SDValue Res = DAG.getNode(X86ISD::CVTTPD2DQ, dl, MVT::v4i32, Src);
+        Res = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, MVT::v2i32, Res, Idx);
RKSimon wrote:
> See above.
I meant using ISD::FP_TO_SINT instead of X86ISD::CVTTPD2DQ



More information about the llvm-commits mailing list