Bug 157025 - [patch] gcc(1): gcc Bug 28796 - __builtin_nan() and __builtin_unordered() inconsistent
Summary: [patch] gcc(1): gcc Bug 28796 - __builtin_nan() and __builtin_unordered() inc...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: gnu (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: Pedro F. Giffuni
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-14 03:30 UTC by Pedro F. Giffuni
Modified: 2012-02-03 21:30 UTC (History)
0 users

See Also:


Attachments
file.diff (1.68 KB, patch)
2011-05-14 03:30 UTC, Pedro F. Giffuni
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pedro F. Giffuni 2011-05-14 03:30:06 UTC
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.

Fix: Patch attached.

Patch attached with submission follows:
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.
Comment 1 dfilter service freebsd_committer freebsd_triage 2011-12-21 01:58:49 UTC
Author: pfg
Date: Wed Dec 21 01:58:35 2011
New Revision: 228756
URL: http://svn.freebsd.org/changeset/base/228756

Log:
  Clean an inconsistency with -ffinite-math-only.
  Backported from the gcc-4_3-branch, revision 118001,
  under the GPLv2.
  
  This issue was also fixed in Apple's gcc.
  
  PR:		157025
  Reviewed by:	mm
  Approved by:	jhb (mentor)
  MFC:		2 weeks

Modified:
  head/contrib/gcc/ChangeLog.gcc43
  head/contrib/gcc/builtins.c

Modified: head/contrib/gcc/ChangeLog.gcc43
==============================================================================
--- head/contrib/gcc/ChangeLog.gcc43	Tue Dec 20 22:56:44 2011	(r228755)
+++ head/contrib/gcc/ChangeLog.gcc43	Wed Dec 21 01:58:35 2011	(r228756)
@@ -96,6 +96,14 @@
 
 	* doc/invoke.texi: Add entry about geode processor.
     
+2006-10-24  Richard Guenther  <rguenther@suse.de>
+
+	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.
+
 2006-10-22  H.J. Lu  <hongjiu.lu@intel.com> (r117958)
 
 	* config.gcc (i[34567]86-*-*): Add tmmintrin.h to extra_headers.

Modified: head/contrib/gcc/builtins.c
==============================================================================
--- head/contrib/gcc/builtins.c	Tue Dec 20 22:56:44 2011	(r228755)
+++ head/contrib/gcc/builtins.c	Wed Dec 21 01:58:35 2011	(r228756)
@@ -8720,7 +8720,7 @@ fold_builtin_classify (tree fndecl, tree
   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 @@ fold_builtin_classify (tree fndecl, tree
       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 @@ fold_builtin_classify (tree fndecl, tree
       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 @@ fold_builtin_unordered_cmp (tree fndecl,
 
   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));
 }
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 2 Pedro F. Giffuni freebsd_committer freebsd_triage 2011-12-21 02:30:00 UTC
State Changed
From-To: open->patched

Committed to current in SVN Revision 225756. 


Comment 3 Pedro F. Giffuni freebsd_committer freebsd_triage 2011-12-21 02:30:00 UTC
Responsible Changed
From-To: freebsd-bugs->pfg

I am taking care of it.
Comment 4 dfilter service freebsd_committer freebsd_triage 2012-01-05 02:36:56 UTC
Author: pfg
Date: Thu Jan  5 02:36:37 2012
New Revision: 229554
URL: http://svn.freebsd.org/changeset/base/229554

Log:
  MFC:	r228756
  
  Clean an inconsistency with -ffinite-math-only.
  Backported from the gcc-4_3-branch, revision (118001)
  under the GPLv2.
  This issue was also fixed in Apple's gcc.
  
  PR:		157025
  Reviewed by:	mm
  Approved by:	jhb (mentor)

Modified:
  stable/9/contrib/gcc/ChangeLog.gcc43
  stable/9/contrib/gcc/builtins.c
Directory Properties:
  stable/9/contrib/gcc/   (props changed)

Modified: stable/9/contrib/gcc/ChangeLog.gcc43
==============================================================================
--- stable/9/contrib/gcc/ChangeLog.gcc43	Thu Jan  5 02:16:55 2012	(r229553)
+++ stable/9/contrib/gcc/ChangeLog.gcc43	Thu Jan  5 02:36:37 2012	(r229554)
@@ -96,6 +96,14 @@
 
 	* doc/invoke.texi: Add entry about geode processor.
     
+2006-10-24  Richard Guenther  <rguenther@suse.de>
+
+	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.
+
 2006-10-22  H.J. Lu  <hongjiu.lu@intel.com> (r117958)
 
 	* config.gcc (i[34567]86-*-*): Add tmmintrin.h to extra_headers.

Modified: stable/9/contrib/gcc/builtins.c
==============================================================================
--- stable/9/contrib/gcc/builtins.c	Thu Jan  5 02:16:55 2012	(r229553)
+++ stable/9/contrib/gcc/builtins.c	Thu Jan  5 02:36:37 2012	(r229554)
@@ -8720,7 +8720,7 @@ fold_builtin_classify (tree fndecl, tree
   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 @@ fold_builtin_classify (tree fndecl, tree
       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 @@ fold_builtin_classify (tree fndecl, tree
       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 @@ fold_builtin_unordered_cmp (tree fndecl,
 
   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));
 }
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 5 Pedro F. Giffuni freebsd_committer freebsd_triage 2012-01-05 02:46:31 UTC
State Changed
From-To: patched->closed

Committed and MFC'd/9.
Comment 6 dfilter service freebsd_committer freebsd_triage 2012-02-03 21:26:35 UTC
Author: pfg
Date: Fri Feb  3 21:26:25 2012
New Revision: 230959
URL: http://svn.freebsd.org/changeset/base/230959

Log:
  MFC:	r228756
  
  Clean an inconsistency with -ffinite-math-only.
  Backported from the gcc-4_3-branch, revision (118001)
  under the GPLv2.
  This issue was also fixed in Apple's gcc.
  
  PR:		157025
  Reviewed by:	mm
  Approved by:	jhb (mentor)

Modified:
  stable/8/contrib/gcc/ChangeLog.gcc43
  stable/8/contrib/gcc/builtins.c
Directory Properties:
  stable/8/contrib/gcc/   (props changed)

Modified: stable/8/contrib/gcc/ChangeLog.gcc43
==============================================================================
--- stable/8/contrib/gcc/ChangeLog.gcc43	Fri Feb  3 21:24:28 2012	(r230958)
+++ stable/8/contrib/gcc/ChangeLog.gcc43	Fri Feb  3 21:26:25 2012	(r230959)
@@ -96,6 +96,14 @@
 
 	* doc/invoke.texi: Add entry about geode processor.
     
+2006-10-24  Richard Guenther  <rguenther@suse.de>
+
+	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.
+
 2006-10-22  H.J. Lu  <hongjiu.lu@intel.com> (r117958)
 
 	* config.gcc (i[34567]86-*-*): Add tmmintrin.h to extra_headers.

Modified: stable/8/contrib/gcc/builtins.c
==============================================================================
--- stable/8/contrib/gcc/builtins.c	Fri Feb  3 21:24:28 2012	(r230958)
+++ stable/8/contrib/gcc/builtins.c	Fri Feb  3 21:26:25 2012	(r230959)
@@ -8720,7 +8720,7 @@ fold_builtin_classify (tree fndecl, tree
   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 @@ fold_builtin_classify (tree fndecl, tree
       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 @@ fold_builtin_classify (tree fndecl, tree
       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 @@ fold_builtin_unordered_cmp (tree fndecl,
 
   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));
 }
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"