Don't convert store double C, Ptr to store long C, Ptr if i64 is not a legal type.
authorEvan Cheng <evan.cheng@apple.com>
Mon, 11 Dec 2006 17:25:19 +0000 (17:25 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Mon, 11 Dec 2006 17:25:19 +0000 (17:25 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32434 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/DAGCombiner.cpp

index 750f0bb6f562828e1e8c785f372b7e062fb45d53..f04f4013777994fc56ae62d25540f2af84c8d3fd 100644 (file)
@@ -3035,17 +3035,20 @@ SDOperand DAGCombiner::visitSTORE(SDNode *N) {
   }
   
   // Turn 'store float 1.0, Ptr' -> 'store int 0x12345678, Ptr'
-  // FIXME: We shouldn't do this for TargetConstantFP's.
   if (ConstantFPSDNode *CFP = dyn_cast<ConstantFPSDNode>(Value)) {
-    SDOperand Tmp;
-    if (CFP->getValueType(0) == MVT::f32) {
-      Tmp = DAG.getConstant(FloatToBits(CFP->getValue()), MVT::i32);
-    } else {
-      assert(CFP->getValueType(0) == MVT::f64 && "Unknown FP type!");
-      Tmp = DAG.getConstant(DoubleToBits(CFP->getValue()), MVT::i64);
+    if (Value.getOpcode() != ISD::TargetConstantFP) {
+      SDOperand Tmp;
+      if (CFP->getValueType(0) == MVT::f32) {
+        Tmp = DAG.getConstant(FloatToBits(CFP->getValue()), MVT::i32);
+        return DAG.getStore(Chain, Tmp, Ptr, ST->getSrcValue(),
+                            ST->getSrcValueOffset());
+      } else if (TLI.isTypeLegal(MVT::i64)) {
+        assert(CFP->getValueType(0) == MVT::f64 && "Unknown FP type!");
+        Tmp = DAG.getConstant(DoubleToBits(CFP->getValue()), MVT::i64);
+        return DAG.getStore(Chain, Tmp, Ptr, ST->getSrcValue(),
+                            ST->getSrcValueOffset());
+      }
     }
-    return DAG.getStore(Chain, Tmp, Ptr, ST->getSrcValue(),
-                        ST->getSrcValueOffset());
   }
 
   if (CombinerAA) {