[dragonegg] r182663 - Enable fast math IR optimizations when passed -ffast-math.
Duncan Sands
baldrick at free.fr
Fri May 24 12:04:07 PDT 2013
Author: baldrick
Date: Fri May 24 14:04:06 2013
New Revision: 182663
URL: http://llvm.org/viewvc/llvm-project?rev=182663&view=rev
Log:
Enable fast math IR optimizations when passed -ffast-math.
Added:
dragonegg/trunk/test/validator/c/fast-math.c
Modified:
dragonegg/trunk/src/Convert.cpp
dragonegg/trunk/test/compilator/compilator-lit.cfg
Modified: dragonegg/trunk/src/Convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=182663&r1=182662&r2=182663&view=diff
==============================================================================
--- dragonegg/trunk/src/Convert.cpp (original)
+++ dragonegg/trunk/src/Convert.cpp Fri May 24 14:04:06 2013
@@ -1639,6 +1639,19 @@ void TreeToLLVM::EmitBasicBlock(basic_bl
}
Function *TreeToLLVM::EmitFunction() {
+ FastMathFlags FMF;
+ if (flag_finite_math_only) {
+ FMF.setNoInfs();
+ FMF.setNoNaNs();
+ }
+ if (!flag_signed_zeros)
+ FMF.setNoSignedZeros();
+ if (flag_reciprocal_math)
+ FMF.setAllowReciprocal();
+ if (flag_unsafe_math_optimizations && flag_finite_math_only)
+ FMF.setUnsafeAlgebra();
+ Builder.SetFastMathFlags(FMF);
+
// Set up parameters and prepare for return, for the function.
StartFunctionBody();
Modified: dragonegg/trunk/test/compilator/compilator-lit.cfg
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/test/compilator/compilator-lit.cfg?rev=182663&r1=182662&r2=182663&view=diff
==============================================================================
--- dragonegg/trunk/test/compilator/compilator-lit.cfg (original)
+++ dragonegg/trunk/test/compilator/compilator-lit.cfg Fri May 24 14:04:06 2013
@@ -39,8 +39,8 @@ def addMutuallyExclusiveFlags(flags):
addMutuallyExclusiveFlags([None, '-O1', '-O2', '-O3'])
# The following are not mutually exclusive, but pretending they are speeds up
# testing. Doing this fails to catch tests that pass with -g and also with
-# -march=native but fail with -g -march=native. Do such tests even exist?
-addMutuallyExclusiveFlags([None, '-g', '-march=native'])
+# -march=native but fail with -g -march=native etc.
+addMutuallyExclusiveFlags([None, '-g', '-march=native', '-ffast-math'])
config.skip = [
'gcc-testsuite/g++.dg/eh/cleanup1.C', # PR11811
Added: dragonegg/trunk/test/validator/c/fast-math.c
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/test/validator/c/fast-math.c?rev=182663&view=auto
==============================================================================
--- dragonegg/trunk/test/validator/c/fast-math.c (added)
+++ dragonegg/trunk/test/validator/c/fast-math.c Fri May 24 14:04:06 2013
@@ -0,0 +1,12 @@
+// RUN: %dragonegg -S %s -o - | FileCheck -check-prefix=DEFAULT %s
+// RUN: %dragonegg -S %s -o - -ffast-math | FileCheck -check-prefix=FASTMATH %s
+// RUN: %dragonegg -S %s -o - -ffinite-math-only | FileCheck -check-prefix=FINITEMATHONLY %s
+// RUN: %dragonegg -S %s -o - -fno-signed-zeros | FileCheck -check-prefix=NOSIGNEDZEROS %s
+
+double fm(double x, double y) {
+ return x+y;
+// DEFAULT: fadd double
+// FASTMATH: fadd fast
+// FINITEMATHONLY: fadd nnan ninf
+// NOSIGNEDZEROS: fadd nsz
+}
More information about the llvm-commits
mailing list