[Bug middle-end/20493] [4.0/4.1 Regression] Bootstrap failure

John David Anglin dave@hiauly1.hia.nrc.ca
Sat Mar 19 17:49:00 GMT 2005


> On Sat, 19 Mar 2005, John David Anglin wrote:
> > The attached change appears to fix the problem.  I have done complete
> > bootstraps and checks using hppa-unknown-linux-gnu (4.1.0) and
> > hppa2.0w-hp-hpux11.11 (4.0.0).  I don't see any regressions related
> > to this isssue.
> 
> 
> Could you repost to gcc-patches with a suitable ChangeLog entry?
> These changes are preapproved for both mainline and the 4.0 branch.

The enclosed change was preapproved by Roger Sayle.  See discussion
in <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20493>.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

2005-03-19  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>

	PR middle-end/20493
	* fold-const.c (fold_widened_comparison): Don't optimize casts of
	function pointers on targets that require function pointer
	canonicalization.
	(fold_sign_changed_comparison): Likewise.

Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.543
diff -u -3 -p -r1.543 fold-const.c
--- fold-const.c	16 Mar 2005 02:20:05 -0000	1.543
+++ fold-const.c	18 Mar 2005 18:07:14 -0000
@@ -6074,6 +6074,15 @@ fold_widened_comparison (enum tree_code 
     return NULL_TREE;
   shorter_type = TREE_TYPE (arg0_unw);
 
+#ifdef HAVE_canonicalize_funcptr_for_compare
+  /* Disable this optimization if we're casting a function pointer
+     type on targets that require function pointer canonicalization.  */
+  if (HAVE_canonicalize_funcptr_for_compare
+      && TREE_CODE (shorter_type) == POINTER_TYPE
+      && TREE_CODE (TREE_TYPE (shorter_type)) == FUNCTION_TYPE)
+    return NULL_TREE;
+#endif
+
   if (TYPE_PRECISION (TREE_TYPE (arg0)) <= TYPE_PRECISION (shorter_type))
     return NULL_TREE;
 
@@ -6156,6 +6165,15 @@ fold_sign_changed_comparison (enum tree_
   arg0_inner = TREE_OPERAND (arg0, 0);
   inner_type = TREE_TYPE (arg0_inner);
 
+#ifdef HAVE_canonicalize_funcptr_for_compare
+  /* Disable this optimization if we're casting a function pointer
+     type on targets that require function pointer canonicalization.  */
+  if (HAVE_canonicalize_funcptr_for_compare
+      && TREE_CODE (inner_type) == POINTER_TYPE
+      && TREE_CODE (TREE_TYPE (inner_type)) == FUNCTION_TYPE)
+    return NULL_TREE;
+#endif
+
   if (TYPE_PRECISION (inner_type) != TYPE_PRECISION (outer_type))
     return NULL_TREE;
 



More information about the Gcc-patches mailing list