add a couple of missing folds
authorChris Lattner <sabre@nondot.org>
Mon, 13 Mar 2006 06:26:26 +0000 (06:26 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 13 Mar 2006 06:26:26 +0000 (06:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26724 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/DAGCombiner.cpp

index 1e05d583e8374ef3fa3b61b1a2731e01da2ca1cc..1d6d40eb9a9a6e2a3631c82ca12502dfc8fcd12b 100644 (file)
@@ -2102,6 +2102,18 @@ SDOperand DAGCombiner::visitFP_ROUND(SDNode *N) {
   // fold (fp_round c1fp) -> c1fp
   if (N0CFP)
     return DAG.getNode(ISD::FP_ROUND, VT, N0);
+  
+  // fold (fp_round (fp_extend x)) -> x
+  if (N0.getOpcode() == ISD::FP_EXTEND && VT == N0.getOperand(0).getValueType())
+    return N0.getOperand(0);
+  
+  // fold (fp_round (copysign X, Y)) -> (copysign (fp_round X), Y)
+  if (N0.getOpcode() == ISD::FCOPYSIGN && N0.Val->hasOneUse()) {
+    SDOperand Tmp = DAG.getNode(ISD::FP_ROUND, VT, N0.getOperand(0));
+    AddToWorkList(Tmp.Val);
+    return DAG.getNode(ISD::FCOPYSIGN, VT, Tmp, N0.getOperand(1));
+  }
+  
   return SDOperand();
 }