Revise per review of previous patch.
authorDale Johannesen <dalej@apple.com>
Fri, 31 Aug 2007 17:03:33 +0000 (17:03 +0000)
committerDale Johannesen <dalej@apple.com>
Fri, 31 Aug 2007 17:03:33 +0000 (17:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41645 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/StringExtras.h
lib/CodeGen/SelectionDAG/SelectionDAG.cpp
lib/Target/IA64/IA64ISelDAGToDAG.cpp

index b56c183a79f60c28add575ad9f3ab5a2ebadb5d2..d292607fd5d491a6be8ad196d9e48d9321519a65 100644 (file)
@@ -93,7 +93,7 @@ static inline std::string ftostr(double V) {
   return B;
 }
 
-static inline std::string ftostr(APFloat V) {
+static inline std::string ftostr(const APFloat& V) {
   if (&V.getSemantics() == &APFloat::IEEEsingle)
     return ftostr(V.convertToDouble());
   else if (&V.getSemantics() == &APFloat::IEEEdouble)
index f4ee33f36abb635c18f1813cd3fd78f883f56448..156c73959f7c2b2292dbee0be276719841e5f06f 100644 (file)
@@ -979,20 +979,32 @@ SDOperand SelectionDAG::FoldSetCC(MVT::ValueType VT, SDOperand N1,
       APFloat::cmpResult R = N1C->getValueAPF().compare(N2C->getValueAPF());
       switch (Cond) {
       default: break;
-      case ISD::SETOEQ:
-      case ISD::SETEQ:  return getConstant(R==APFloat::cmpEqual, VT);
-      case ISD::SETONE:
-      case ISD::SETNE:  return getConstant(R==APFloat::cmpGreaterThan ||
+      case ISD::SETEQ:  if (R==APFloat::cmpUnordered) 
+                          return getNode(ISD::UNDEF, VT);
+                        // fall through
+      case ISD::SETOEQ: return getConstant(R==APFloat::cmpEqual, VT);
+      case ISD::SETNE:  if (R==APFloat::cmpUnordered) 
+                          return getNode(ISD::UNDEF, VT);
+                        // fall through
+      case ISD::SETONE: return getConstant(R==APFloat::cmpGreaterThan ||
                                            R==APFloat::cmpLessThan, VT);
-      case ISD::SETOLT:
-      case ISD::SETLT:  return getConstant(R==APFloat::cmpLessThan, VT);
-      case ISD::SETOGT:
-      case ISD::SETGT:  return getConstant(R==APFloat::cmpGreaterThan, VT);
-      case ISD::SETOLE:
-      case ISD::SETLE:  return getConstant(R==APFloat::cmpLessThan ||
+      case ISD::SETLT:  if (R==APFloat::cmpUnordered) 
+                          return getNode(ISD::UNDEF, VT);
+                        // fall through
+      case ISD::SETOLT: return getConstant(R==APFloat::cmpLessThan, VT);
+      case ISD::SETGT:  if (R==APFloat::cmpUnordered) 
+                          return getNode(ISD::UNDEF, VT);
+                        // fall through
+      case ISD::SETOGT: return getConstant(R==APFloat::cmpGreaterThan, VT);
+      case ISD::SETLE:  if (R==APFloat::cmpUnordered) 
+                          return getNode(ISD::UNDEF, VT);
+                        // fall through
+      case ISD::SETOLE: return getConstant(R==APFloat::cmpLessThan ||
                                            R==APFloat::cmpEqual, VT);
-      case ISD::SETOGE:
-      case ISD::SETGE:  return getConstant(R==APFloat::cmpGreaterThan ||
+      case ISD::SETGE:  if (R==APFloat::cmpUnordered) 
+                          return getNode(ISD::UNDEF, VT);
+                        // fall through
+      case ISD::SETOGE: return getConstant(R==APFloat::cmpGreaterThan ||
                                            R==APFloat::cmpEqual, VT);
       case ISD::SETO:   return getConstant(R!=APFloat::cmpUnordered, VT);
       case ISD::SETUO:  return getConstant(R==APFloat::cmpUnordered, VT);
index 7421978dae9e7eaa483c070f6b275975be2a3cb0..7fa90b07ba8d68ab2bff8d7c0518df1425268dac 100644 (file)
@@ -404,9 +404,11 @@ SDNode *IA64DAGToDAGISel::Select(SDOperand Op) {
     SDOperand Chain = CurDAG->getEntryNode(); // this is a constant, so..
 
     SDOperand V;
-    if (cast<ConstantFPSDNode>(N)->getValueAPF().isPosZero()) {
+    ConstantFPSDNode* N2 = cast<ConstantFPSDNode>(N);
+    if (N2->getValueAPF().isPosZero()) {
       V = CurDAG->getCopyFromReg(Chain, IA64::F0, MVT::f64);
-    } else if (cast<ConstantFPSDNode>(N)->isExactlyValue(APFloat(+1.0))) {
+    } else if (N2->isExactlyValue(N2->getValueType(0) == MVT::f32 ? 
+                                  APFloat(+1.0f) : APFloat(+1.0))) {
       V = CurDAG->getCopyFromReg(Chain, IA64::F1, MVT::f64);
     } else
       assert(0 && "Unexpected FP constant!");