This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix fold_indirect_ref
- From: Richard Guenther <rguenth at tat dot physik dot uni-tuebingen dot de>
- To: Jeffrey A Law <law at redhat dot com>
- Cc: Andrew Pinski <pinskia at physics dot uc dot edu>,Jakub Jelinek <jakub at redhat dot com>, <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 13 May 2005 14:53:47 +0200 (CEST)
- Subject: Re: [PATCH] Fix fold_indirect_ref
On Thu, 12 May 2005, Jeffrey A Law wrote:
> On Thu, 2005-05-12 at 15:10 -0400, Andrew Pinski wrote:
> > On May 12, 2005, at 2:42 PM, Jakub Jelinek wrote:
> >
> > > On Tue, May 10, 2005 at 05:40:32PM +0200, Richard Guenther wrote:
> > >> 2005-04-28 Richard Guenther <rguenth@gcc.gnu.org>
> > >>
> > >> * fold-const.c (fold_indirect_ref_1): Avoid removing
> > >> NOP_EXPRs with type qualifiers like const.
> > >
> > > This patch causes a regression on gcc-4_0-branch in g++.dg/opt/temp1.C,
> > > which is now miscompiled on at least i386/x86_64/ppc/ppc64/ia64.
> > > Can you please look into it or revert?
> >
> > God I how I hate GCC's type system.
> Something doesn't make any sense here -- Richard's change merely reduces
> the number of NOP_EXPRs that are stripped. If it's causing a regression
> then it must be exposing some kind of latent bug elsewhere.
To throw in another point before I have to leave for some time, the
types in fold_indirect_ref and/or build_fold_indirect_ref cannot be
really right in any cases. Like shown by the following completely
untested patch.
Richard.
Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.578
diff -c -3 -p -r1.578 fold-const.c
*** fold-const.c 11 May 2005 15:21:23 -0000 1.578
--- fold-const.c 13 May 2005 12:52:11 -0000
*************** build_fold_indirect_ref (tree t)
*** 11429,11435 ****
tree sub = fold_indirect_ref_1 (t);
if (sub)
! return sub;
else
return build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (t)), t);
}
--- 11455,11461 ----
tree sub = fold_indirect_ref_1 (t);
if (sub)
! return fold_convert (TREE_TYPE (TREE_TYPE (t)), sub);
else
return build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (t)), t);
}
*************** fold_indirect_ref (tree t)
*** 11441,11447 ****
{
tree sub = fold_indirect_ref_1 (TREE_OPERAND (t, 0));
! if (sub)
return sub;
else
return t;
--- 11467,11473 ----
{
tree sub = fold_indirect_ref_1 (TREE_OPERAND (t, 0));
! if (sub && TREE_TYPE (t) == TREE_TYPE (sub))
return sub;
else
return t;