]> git.ipfire.org Git - thirdparty/gcc.git/commit
c-family: Add more predefined macros for math flags
authorMatthias Kretz <m.kretz@gsi.de>
Wed, 30 Jun 2021 08:41:33 +0000 (10:41 +0200)
committerMatthias Kretz <m.kretz@gsi.de>
Mon, 20 Sep 2021 13:13:11 +0000 (15:13 +0200)
commit1949d7540a0322993bcae2f8893e2dbd29209040
treed0c88b42ad3ae57574993673ea95ff691b2f4ecf
parent71a4bdada59d2d6d1f17c949eaf9377ebb7a8854
c-family: Add more predefined macros for math flags

Library code, especially in headers, sometimes needs to know how the
compiler interprets / optimizes floating-point types and operations.
This information can be used for additional optimizations or for
ensuring correctness. This change makes -freciprocal-math,
-fno-signed-zeros, -fno-trapping-math, -fassociative-math, and
-frounding-math report their state via corresponding pre-defined macros.

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
gcc/testsuite/ChangeLog:

* gcc.dg/associative-math-1.c: New test.
* gcc.dg/associative-math-2.c: New test.
* gcc.dg/no-signed-zeros-1.c: New test.
* gcc.dg/no-signed-zeros-2.c: New test.
* gcc.dg/no-trapping-math-1.c: New test.
* gcc.dg/no-trapping-math-2.c: New test.
* gcc.dg/reciprocal-math-1.c: New test.
* gcc.dg/reciprocal-math-2.c: New test.
* gcc.dg/rounding-math-1.c: New test.
* gcc.dg/rounding-math-2.c: New test.

gcc/c-family/ChangeLog:

* c-cppbuiltin.c (c_cpp_builtins_optimize_pragma): Define or
undefine __RECIPROCAL_MATH__, __NO_SIGNED_ZEROS__,
__NO_TRAPPING_MATH__, __ASSOCIATIVE_MATH__, and
__ROUNDING_MATH__ according to the new optimization flags.

gcc/ChangeLog:

* cppbuiltin.c (define_builtin_macros_for_compilation_flags):
Define __RECIPROCAL_MATH__, __NO_SIGNED_ZEROS__,
__NO_TRAPPING_MATH__, __ASSOCIATIVE_MATH__, and
__ROUNDING_MATH__ according to their corresponding flags.
* doc/cpp.texi: Document __RECIPROCAL_MATH__,
__NO_SIGNED_ZEROS__, __NO_TRAPPING_MATH__, __ASSOCIATIVE_MATH__,
and __ROUNDING_MATH__.
13 files changed:
gcc/c-family/c-cppbuiltin.c
gcc/cppbuiltin.c
gcc/doc/cpp.texi
gcc/testsuite/gcc.dg/associative-math-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/associative-math-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/no-signed-zeros-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/no-signed-zeros-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/no-trapping-math-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/no-trapping-math-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/reciprocal-math-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/reciprocal-math-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/rounding-math-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/rounding-math-2.c [new file with mode: 0644]