[llvm-commits] CVS: llvm/lib/VMCore/ConstantFolding.cpp

Reid Spencer reid at x10sys.com
Wed Jan 10 16:26:00 PST 2007



Changes in directory llvm/lib/VMCore:

ConstantFolding.cpp updated: 1.125 -> 1.126
---
Log message:

Implement better constant folding of unordered FCMP predicates.


---
Diffs of the changes:  (+27 -7)

 ConstantFolding.cpp |   34 +++++++++++++++++++++++++++-------
 1 files changed, 27 insertions(+), 7 deletions(-)


Index: llvm/lib/VMCore/ConstantFolding.cpp
diff -u llvm/lib/VMCore/ConstantFolding.cpp:1.125 llvm/lib/VMCore/ConstantFolding.cpp:1.126
--- llvm/lib/VMCore/ConstantFolding.cpp:1.125	Wed Jan  3 20:13:20 2007
+++ llvm/lib/VMCore/ConstantFolding.cpp	Wed Jan 10 18:25:45 2007
@@ -1110,18 +1110,38 @@
     case FCmpInst::FCMP_FALSE: return ConstantBool::getFalse();
     case FCmpInst::FCMP_TRUE:  return ConstantBool::getTrue();
     case FCmpInst::FCMP_UNO:
-    case FCmpInst::FCMP_ORD:   break; // Can't fold these
+      return ConstantBool::get(C1Val != C1Val || C2Val != C2Val);
+    case FCmpInst::FCMP_ORD:
+      return ConstantBool::get(C1Val == C1Val && C2Val == C2Val);
     case FCmpInst::FCMP_UEQ:
+      if (C1Val != C1Val || C2Val != C2Val)
+        return ConstantBool::getTrue();
+      /* FALL THROUGH */
     case FCmpInst::FCMP_OEQ:   return ConstantBool::get(C1Val == C2Val);
-    case FCmpInst::FCMP_ONE:
-    case FCmpInst::FCMP_UNE:   return ConstantBool::get(C1Val != C2Val);
-    case FCmpInst::FCMP_OLT: 
-    case FCmpInst::FCMP_ULT:   return ConstantBool::get(C1Val < C2Val);
+    case FCmpInst::FCMP_UNE:
+      if (C1Val != C1Val || C2Val != C2Val)
+        return ConstantBool::getTrue();
+      /* FALL THROUGH */
+    case FCmpInst::FCMP_ONE:   return ConstantBool::get(C1Val != C2Val);
+    case FCmpInst::FCMP_ULT: 
+      if (C1Val != C1Val || C2Val != C2Val)
+        return ConstantBool::getTrue();
+      /* FALL THROUGH */
+    case FCmpInst::FCMP_OLT:   return ConstantBool::get(C1Val < C2Val);
     case FCmpInst::FCMP_UGT:
+      if (C1Val != C1Val || C2Val != C2Val)
+        return ConstantBool::getTrue();
+      /* FALL THROUGH */
     case FCmpInst::FCMP_OGT:   return ConstantBool::get(C1Val > C2Val);
-    case FCmpInst::FCMP_OLE:
-    case FCmpInst::FCMP_ULE:   return ConstantBool::get(C1Val <= C2Val);
+    case FCmpInst::FCMP_ULE:
+      if (C1Val != C1Val || C2Val != C2Val)
+        return ConstantBool::getTrue();
+      /* FALL THROUGH */
+    case FCmpInst::FCMP_OLE:   return ConstantBool::get(C1Val <= C2Val);
     case FCmpInst::FCMP_UGE:
+      if (C1Val != C1Val || C2Val != C2Val)
+        return ConstantBool::getTrue();
+      /* FALL THROUGH */
     case FCmpInst::FCMP_OGE:   return ConstantBool::get(C1Val >= C2Val);
     }
   } else if (const ConstantPacked *CP1 = dyn_cast<ConstantPacked>(C1)) {






More information about the llvm-commits mailing list