This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH]: PR middle-end/29335 Restrict MPFR opts to targets where float base is two
- From: "Kaveh R. GHAZI" <ghazi at caip dot rutgers dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 12 Dec 2006 23:26:11 -0500 (EST)
- Subject: [PATCH]: PR middle-end/29335 Restrict MPFR opts to targets where float base is two
Based on discussion here:
http://gcc.gnu.org/ml/gcc/2006-12/msg00072.html
I've created the patch below which restricts the use of MPFR to handle
transcendental optimizations to targets where float base equals two.
Tested on sparc-sun-solaris2.10, no regressions.
Okay for mainline?
Thanks,
--Kaveh
2006-12-10 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
PR middle-end/29335
* builtins.c (do_mpfr_arg1, do_mpfr_arg2, do_mpfr_arg3,
do_mpfr_sincos): Ensure target base equals two.
diff -rup orig/egcc-SVN20061209/gcc/builtins.c egcc-SVN20061209/gcc/builtins.c
--- orig/egcc-SVN20061209/gcc/builtins.c 2006-12-07 20:01:47.000000000 -0500
+++ egcc-SVN20061209/gcc/builtins.c 2006-12-10 20:39:50.693205583 -0500
@@ -11557,7 +11557,10 @@ do_mpfr_arg1 (tree arg, tree type, int (
STRIP_NOPS (arg);
- if (TREE_CODE (arg) == REAL_CST && ! TREE_CONSTANT_OVERFLOW (arg))
+ /* To proceed, MPFR must exactly represent the target floating point
+ format, which only happens when the target base equals two. */
+ if (REAL_MODE_FORMAT (TYPE_MODE (type))->b == 2
+ && TREE_CODE (arg) == REAL_CST && ! TREE_CONSTANT_OVERFLOW (arg))
{
const REAL_VALUE_TYPE *const ra = &TREE_REAL_CST (arg);
@@ -11596,7 +11599,10 @@ do_mpfr_arg2 (tree arg1, tree arg2, tree
STRIP_NOPS (arg1);
STRIP_NOPS (arg2);
- if (TREE_CODE (arg1) == REAL_CST && ! TREE_CONSTANT_OVERFLOW (arg1)
+ /* To proceed, MPFR must exactly represent the target floating point
+ format, which only happens when the target base equals two. */
+ if (REAL_MODE_FORMAT (TYPE_MODE (type))->b == 2
+ && TREE_CODE (arg1) == REAL_CST && ! TREE_CONSTANT_OVERFLOW (arg1)
&& TREE_CODE (arg2) == REAL_CST && ! TREE_CONSTANT_OVERFLOW (arg2))
{
const REAL_VALUE_TYPE *const ra1 = &TREE_REAL_CST (arg1);
@@ -11638,7 +11644,10 @@ do_mpfr_arg3 (tree arg1, tree arg2, tree
STRIP_NOPS (arg2);
STRIP_NOPS (arg3);
- if (TREE_CODE (arg1) == REAL_CST && ! TREE_CONSTANT_OVERFLOW (arg1)
+ /* To proceed, MPFR must exactly represent the target floating point
+ format, which only happens when the target base equals two. */
+ if (REAL_MODE_FORMAT (TYPE_MODE (type))->b == 2
+ && TREE_CODE (arg1) == REAL_CST && ! TREE_CONSTANT_OVERFLOW (arg1)
&& TREE_CODE (arg2) == REAL_CST && ! TREE_CONSTANT_OVERFLOW (arg2)
&& TREE_CODE (arg3) == REAL_CST && ! TREE_CONSTANT_OVERFLOW (arg3))
{
@@ -11676,17 +11685,20 @@ do_mpfr_arg3 (tree arg1, tree arg2, tree
static tree
do_mpfr_sincos (tree arg, tree arg_sinp, tree arg_cosp)
{
+ tree const type = TREE_TYPE (arg);
tree result = NULL_TREE;
STRIP_NOPS (arg);
- if (TREE_CODE (arg) == REAL_CST && ! TREE_CONSTANT_OVERFLOW (arg))
+ /* To proceed, MPFR must exactly represent the target floating point
+ format, which only happens when the target base equals two. */
+ if (REAL_MODE_FORMAT (TYPE_MODE (type))->b == 2
+ && TREE_CODE (arg) == REAL_CST && ! TREE_CONSTANT_OVERFLOW (arg))
{
const REAL_VALUE_TYPE *const ra = &TREE_REAL_CST (arg);
if (!real_isnan (ra) && !real_isinf (ra))
{
- tree const type = TREE_TYPE (arg);
const int prec = REAL_MODE_FORMAT (TYPE_MODE (type))->p;
tree result_s, result_c;
int inexact;