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

Andrew Lenharth alenhar2 at cs.uiuc.edu
Mon May 2 14:26:04 PDT 2005



Changes in directory llvm/lib/VMCore:

ConstantFolding.cpp updated: 1.74 -> 1.75
---
Log message:

fold fp div by 0 to inf, the way gcc does.  This is legal according to the FP spec

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

 ConstantFolding.cpp |    7 +++++++
 1 files changed, 7 insertions(+)


Index: llvm/lib/VMCore/ConstantFolding.cpp
diff -u llvm/lib/VMCore/ConstantFolding.cpp:1.74 llvm/lib/VMCore/ConstantFolding.cpp:1.75
--- llvm/lib/VMCore/ConstantFolding.cpp:1.74	Sun Apr 24 17:27:20 2005
+++ llvm/lib/VMCore/ConstantFolding.cpp	Mon May  2 16:25:47 2005
@@ -470,6 +470,13 @@
                                    (BuiltinType)V2->getValue());
     return ConstantClass::get(*Ty, Result);
   }
+  static Constant *Div(const ConstantClass *V1, const ConstantClass *V2) {
+    if (V2->isExactlyValue(0.0)) return ConstantClass::get(*Ty, INFINITY);
+    if (V2->isExactlyValue(-0.0)) return ConstantClass::get(*Ty, -INFINITY);
+    if (V2->isNullValue()) return 0;
+    BuiltinType R = (BuiltinType)V1->getValue() / (BuiltinType)V2->getValue();
+    return ConstantClass::get(*Ty, R);
+  }
 };
 
 






More information about the llvm-commits mailing list