aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/VMCore/Constants.cpp3
-rw-r--r--test/Assembler/2004-01-22-FloatNormalization.ll5
-rw-r--r--test/Assembler/2004-12-06-ConstantFloatRange.ll1
-rw-r--r--test/Verifier/2004-01-22-FloatNormalization.ll6
4 files changed, 9 insertions, 6 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index 080baf8d63..c1324b6b26 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -482,6 +482,9 @@ bool ConstantFP::isValueValidForType(const Type *Ty, double Val) {
// TODO: Figure out how to test if a double can be cast to a float!
case Type::FloatTyID:
+ float FV = float(Val);
+ double DV = double(FV);
+ return IsNAN(Val) || Val == DV;
case Type::DoubleTyID:
return true; // This is the largest type...
}
diff --git a/test/Assembler/2004-01-22-FloatNormalization.ll b/test/Assembler/2004-01-22-FloatNormalization.ll
deleted file mode 100644
index 5eae402dfd..0000000000
--- a/test/Assembler/2004-01-22-FloatNormalization.ll
+++ /dev/null
@@ -1,5 +0,0 @@
-; RUN: llvm-as < %s -o /dev/null -f
-
-; make sure that 'float' values have their value properly truncated.
-
-global float 0x1
diff --git a/test/Assembler/2004-12-06-ConstantFloatRange.ll b/test/Assembler/2004-12-06-ConstantFloatRange.ll
index 30d103c572..61f2b77b3f 100644
--- a/test/Assembler/2004-12-06-ConstantFloatRange.ll
+++ b/test/Assembler/2004-12-06-ConstantFloatRange.ll
@@ -1,5 +1,4 @@
; RUN: llvm-as %s -o /dev/null 2>&1 | grep "constant invalid for type"
-; XFAIL: *
;; This is a testcase for PR409
diff --git a/test/Verifier/2004-01-22-FloatNormalization.ll b/test/Verifier/2004-01-22-FloatNormalization.ll
new file mode 100644
index 0000000000..8fbfe19427
--- /dev/null
+++ b/test/Verifier/2004-01-22-FloatNormalization.ll
@@ -0,0 +1,6 @@
+; RUN: llvm-as < %s -o /dev/null -f
+; XFAIL: *
+
+; make sure that invalid 'float' values are caught.
+
+global float 0x1