Handle v2i64 BUILD_VECTOR custom lowering correctly. v2i64 is a legal type,
authorEvan Cheng <evan.cheng@apple.com>
Thu, 20 Apr 2006 00:11:39 +0000 (00:11 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Thu, 20 Apr 2006 00:11:39 +0000 (00:11 +0000)
but i64 is not. If possible, change a i64 op to a f64 (e.g. load, constant)
and then cast it back.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27849 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86ISelLowering.cpp

index 15027c20df95fac703773ad21a5542e2544f1f88..c13d8cd8972daaf4b1dce66b2d02f798bd634473 100644 (file)
@@ -2980,7 +2980,22 @@ SDOperand X86TargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
       if (Elt0IsZero) return Op;
 
       // Zero extend a scalar to a vector.
-      return DAG.getNode(X86ISD::ZEXT_S2VEC, Op.getValueType(), Elt0);
+      if (Elt0.getValueType() != MVT::i64)
+        return DAG.getNode(X86ISD::ZEXT_S2VEC, Op.getValueType(), Elt0);
+
+      // See if we can turn it into a f64 op.
+      bool IsLegal = false;
+      if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(Elt0)) {
+        Elt0 = DAG.getConstantFP(BitsToDouble(C->getValue()), MVT::f64);
+        IsLegal = true;
+      } else if (Elt0.getOpcode() == ISD::LOAD) {
+        Elt0 = DAG.getLoad(MVT::f64, Elt0.getOperand(0), Elt0.getOperand(1),
+                           Elt0.getOperand(2));
+        IsLegal = true;
+      }
+      if (IsLegal)
+        return DAG.getNode(ISD::BIT_CONVERT, MVT::v2i64,
+                           DAG.getNode(X86ISD::ZEXT_S2VEC, MVT::v2f64, Elt0));
     }
 
     if (Values.size() > 2) {