gnu/157025: gcc Bug 28796 - __builtin_nan() and
__builtin_unordered() inconsistent
Pedro Giffuni
giffunip at tutopia.com
Sat May 14 02:30:07 UTC 2011
>Number: 157025
>Category: gnu
>Synopsis: gcc Bug 28796 - __builtin_nan() and __builtin_unordered() inconsistent
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Sat May 14 02:30:06 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator: Pedro Giffuni
>Release: 8.2-Release
>Organization:
>Environment:
FreeBSD mogwai.giffuni.net 8.2-RELEASE FreeBSD 8.2-RELEASE #0: Fri Mar 18 15:35:09 UTC 2011 root at mogwai.giffuni.net:/usr/src/sys/amd64/compile/GENERIC amd64
>Description:
As can be read in the top of Apple's gcc Changelog:
http://opensource.apple.com/source/gcc/gcc-5664/gcc/ChangeLog
The following commit was made:
2006-10-24 Richard Guenther
Radar 5675014
PR middle-end/28796
* builtins.c (fold_builtin_classify): Use HONOR_INFINITIES
and HONOR_NANS instead of MODE_HAS_INFINITIES and MODE_HAS_NANS
for deciding optimizations in consistency with fold-const.c
(fold_builtin_unordered_cmp): Likewise.
_______
Applying this will make our base compiler behave consistently
with -ffinite-math-only and is in accordance to what clang
and newer GCCs do.
>How-To-Repeat:
There is a testcase in gcc bug 28796
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28796
FWIW, This was reported in gnu/153298 too but it was obviated
because the other patches were more important.
>Fix:
Patch attached.
Patch attached with submission follows:
--- gcc/builtins.c.orig 2007-05-19 02:12:19.000000000 +0000
+++ gcc/builtins.c 2011-05-13 20:58:56.000000000 +0000
@@ -8720,7 +8720,7 @@
switch (builtin_index)
{
case BUILT_IN_ISINF:
- if (!MODE_HAS_INFINITIES (TYPE_MODE (TREE_TYPE (arg))))
+ if (!HONOR_INFINITIES (TYPE_MODE (TREE_TYPE (arg))))
return omit_one_operand (type, integer_zero_node, arg);
if (TREE_CODE (arg) == REAL_CST)
@@ -8736,8 +8736,8 @@
return NULL_TREE;
case BUILT_IN_FINITE:
- if (!MODE_HAS_NANS (TYPE_MODE (TREE_TYPE (arg)))
- && !MODE_HAS_INFINITIES (TYPE_MODE (TREE_TYPE (arg))))
+ if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg)))
+ && !HONOR_INFINITIES (TYPE_MODE (TREE_TYPE (arg))))
return omit_one_operand (type, integer_zero_node, arg);
if (TREE_CODE (arg) == REAL_CST)
@@ -8750,7 +8750,7 @@
return NULL_TREE;
case BUILT_IN_ISNAN:
- if (!MODE_HAS_NANS (TYPE_MODE (TREE_TYPE (arg))))
+ if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg))))
return omit_one_operand (type, integer_zero_node, arg);
if (TREE_CODE (arg) == REAL_CST)
@@ -8833,13 +8833,13 @@
if (unordered_code == UNORDERED_EXPR)
{
- if (!MODE_HAS_NANS (TYPE_MODE (TREE_TYPE (arg0))))
+ if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg0))))
return omit_two_operands (type, integer_zero_node, arg0, arg1);
return fold_build2 (UNORDERED_EXPR, type, arg0, arg1);
}
- code = MODE_HAS_NANS (TYPE_MODE (TREE_TYPE (arg0))) ? unordered_code
- : ordered_code;
+ code = HONOR_NANS (TYPE_MODE (TREE_TYPE (arg0))) ? unordered_code
+ : ordered_code;
return fold_build1 (TRUTH_NOT_EXPR, type,
fold_build2 (code, type, arg0, arg1));
}
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list