This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] improve C++ code by changing fold-const.c
- From: Andrew Pinski <pinskia at physics dot uc dot edu>
- To: Andrew Pinski <pinskia at physics dot uc dot edu>
- Cc: Jeff Law <law at redhat dot com>, Roger Sayle <roger at eyesopen dot com>, Diego Novillo <dnovillo at redhat dot com>, Dale Johannesen <dalej at apple dot com>, gcc-patches at gcc dot gnu dot org, Richard Henderson <rth at redhat dot com>, Mark Mitchell <mark at codesourcery dot com>
- Date: Wed, 2 Jun 2004 00:35:45 -0400
- Subject: Re: [PATCH] improve C++ code by changing fold-const.c
- References: <200405210300.i4L30AW5011486@speedy.slc.redhat.com> <40AEB4C1.6090804@codesourcery.com> <4E341518-AB9A-11D8-A4A1-000393A6D2F2@physics.uc.edu> <40AECA32.60900@codesourcery.com> <B47F4926-AF70-11D8-ACD4-000393A6D2F2@physics.uc.edu> <1086124024.2870.5.camel@speedy> <8357EB22-B44D-11D8-AEF3-000393A6D2F2@physics.uc.edu>
On Jun 2, 2004, at 00:30, Andrew Pinski wrote:
On Jun 2, 2004, at 00:12, Jeffrey A Law wrote:
Basically if the inner & outer types are pointer types (which include
references), then we want to compare what each type points to. This
(of course) iterates until one or both types are no longer a pointer
type.
Actually it looks like Dale messed up when he changed
tree_ssa_useless_type_conversion_1 to use the language hook and he
changed
the checking of the how it considers the pointer types compatible,
which
broke this tree_ssa_useless_type_conversion with this respect.
See
<http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-ssa.c.diff?
r1=1.1.4.212&r2=1.1.4.213&f=h>
And here is the patch which fixes the mess up by Dale also improves
all of the code I have been looking at too.
OK? Bootstrapped on powerpc-apple-darwin with no regressions.
Thanks,
Andrew Pinski
ChangeLog:
* tree-ssa.c: Check the type which the pointer points to
instead of the pointer types.
Patch:
Index: tree-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa.c,v
retrieving revision 2.3
diff -u -p -r2.3 tree-ssa.c
--- tree-ssa.c 14 May 2004 02:29:23 -0000 2.3
+++ tree-ssa.c 2 Jun 2004 04:32:50 -0000
@@ -555,7 +555,8 @@ tree_ssa_useless_type_conversion_1 (tree
so strip conversions that just switch between them. */
else if (POINTER_TYPE_P (inner_type)
&& POINTER_TYPE_P (outer_type)
- && lang_hooks.types_compatible_p (inner_type, outer_type))
+ && lang_hooks.types_compatible_p (TREE_TYPE (inner_type),
+ TREE_TYPE (outer_type)))
return true;
/* If both the inner and outer types are integral types, then the