public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR tree-opt/17529, ICE due to *&a not being folded to a[0]
@ 2004-10-24  3:07 Andrew Pinski
  2004-10-27 17:10 ` Jeffrey A Law
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Pinski @ 2004-10-24  3:07 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 688 bytes --]

I think the subject says what causes the problem and the reason why
we don't fold *&a into a[0] is because fold does not handle it
but fold_stmt does.  So what I did was to patch remove_useless_stmts_1
to do the folding for us (this is already done for the second testcase
in the PR, for MODIFY_EXPR).  I also removed the case for SWITCH_EXPR
in remove_useless_stmts_1 because it was not needed at all and just
slowed us down.

OK? Bootstrapped and tested on powerpc-darwin.



ChangeLog:

	* tree-cfg.c (remove_useless_stmts_1) <case SWITCH_EXPR>:
	Don't fold statement.
	<case ASM_EXPR>: Fold the statement.

testsuite/ChangeLog:
	* gcc.c-torture/compile/pr17529.c: Remove the xfail.



[-- Attachment #2: temp.diff.txt --]
[-- Type: text/plain, Size: 1000 bytes --]

Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.89
diff -u -p -r2.89 tree-cfg.c
--- tree-cfg.c	23 Oct 2004 19:17:08 -0000	2.89
+++ tree-cfg.c	24 Oct 2004 01:04:09 -0000
@@ -1600,7 +1600,7 @@ remove_useless_stmts_1 (tree *tp, struct
 	  }
       }
       break;
-    case SWITCH_EXPR:
+    case ASM_EXPR:
       fold_stmt (tp);
       data->last_goto = NULL;
       break;
Index: testsuite/gcc.c-torture/compile/pr17529.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.c-torture/compile/pr17529.c,v
retrieving revision 1.2
diff -u -p -r1.2 pr17529.c
--- testsuite/gcc.c-torture/compile/pr17529.c	18 Oct 2004 22:03:15 -0000	1.2
+++ testsuite/gcc.c-torture/compile/pr17529.c	24 Oct 2004 01:04:09 -0000
@@ -1,4 +1,3 @@
-/* { dg-xfail-if "PR middle-end/17529" { "*-*-*" } { "*" } { "" } } */
 
 static inline void 
 bar (const int * const x) 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Fix PR tree-opt/17529, ICE due to *&a not being folded to a[0]
  2004-10-24  3:07 [PATCH] Fix PR tree-opt/17529, ICE due to *&a not being folded to a[0] Andrew Pinski
@ 2004-10-27 17:10 ` Jeffrey A Law
  2004-10-27 17:30   ` Andrew Pinski
  0 siblings, 1 reply; 4+ messages in thread
From: Jeffrey A Law @ 2004-10-27 17:10 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: GCC Patches

On Sat, 2004-10-23 at 21:08 -0400, Andrew Pinski wrote:
> I think the subject says what causes the problem and the reason why
> we don't fold *&a into a[0] is because fold does not handle it
> but fold_stmt does.
We might consider moving this logic into the fold one day, but I
suspect that's more intrusive than we want to tackle right now.


>  So what I did was to patch remove_useless_stmts_1
> to do the folding for us (this is already done for the second testcase
> in the PR, for MODIFY_EXPR).  I also removed the case for SWITCH_EXPR
> in remove_useless_stmts_1 because it was not needed at all and just
> slowed us down.
> 
> OK? Bootstrapped and tested on powerpc-darwin.
> 
> 
> 
> ChangeLog:
> 
> 	* tree-cfg.c (remove_useless_stmts_1) <case SWITCH_EXPR>:
> 	Don't fold statement.
> 	<case ASM_EXPR>: Fold the statement.
However, I don't think this will fix the other testcase in that
PR:

bar (const int *const x)
{
  int x1 = *x;
}
static const int y[1]={0};
void
foo (void)
{
  bar (y);
}

[ Shouldn't this variant have a test in the testsuite as well? ]

Which seems to indicate you're attacking this in the wrong place.

Jeff

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Fix PR tree-opt/17529, ICE due to *&a not being folded to a[0]
  2004-10-27 17:10 ` Jeffrey A Law
@ 2004-10-27 17:30   ` Andrew Pinski
  2004-10-28  3:19     ` Jeffrey A Law
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Pinski @ 2004-10-27 17:30 UTC (permalink / raw)
  To: law; +Cc: GCC Patches


On Oct 27, 2004, at 1:01 PM, Jeffrey A Law wrote:

> On Sat, 2004-10-23 at 21:08 -0400, Andrew Pinski wrote:
>> I think the subject says what causes the problem and the reason why
>> we don't fold *&a into a[0] is because fold does not handle it
>> but fold_stmt does.
> We might consider moving this logic into the fold one day, but I
> suspect that's more intrusive than we want to tackle right now.
>

> However, I don't think this will fix the other testcase in that
> PR:
>
> bar (const int *const x)
> {
>   int x1 = *x;
> }
> static const int y[1]={0};
> void
> foo (void)
> {
>   bar (y);
> }

The other test is already fixed by the fact we call fold_stmt on
MODIFY_EXPR already.  In fact the only two places in gimple
where INDIRECT_REF (at this point) can show up is ASM_EXPR
or a MODIFY_EXPR so all cases are already handled.

I tested the following the case where you might expect that the
INDIRECT_REF might show up not in either ASM_EXPR or a MODIFY_EXPR
but does not as we use a temporary variable to store the address:
struct t
{
   int i;
};
void f(const int*const);
bar (const struct t *const x)
{
   f(&x->i);
}
static const struct t y[1];
void
foo (void)
{
   bar (y);
}

Thanks,
Andrew Pinski

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Fix PR tree-opt/17529, ICE due to *&a not being folded to a[0]
  2004-10-27 17:30   ` Andrew Pinski
@ 2004-10-28  3:19     ` Jeffrey A Law
  0 siblings, 0 replies; 4+ messages in thread
From: Jeffrey A Law @ 2004-10-28  3:19 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: GCC Patches

On Wed, 2004-10-27 at 13:17 -0400, Andrew Pinski wrote:
> On Oct 27, 2004, at 1:01 PM, Jeffrey A Law wrote:
> 
> > On Sat, 2004-10-23 at 21:08 -0400, Andrew Pinski wrote:
> >> I think the subject says what causes the problem and the reason why
> >> we don't fold *&a into a[0] is because fold does not handle it
> >> but fold_stmt does.
> > We might consider moving this logic into the fold one day, but I
> > suspect that's more intrusive than we want to tackle right now.
> >
> 
> > However, I don't think this will fix the other testcase in that
> > PR:
> >
> > bar (const int *const x)
> > {
> >   int x1 = *x;
> > }
> > static const int y[1]={0};
> > void
> > foo (void)
> > {
> >   bar (y);
> > }
> 
> The other test is already fixed by the fact we call fold_stmt on
> MODIFY_EXPR already.  In fact the only two places in gimple
> where INDIRECT_REF (at this point) can show up is ASM_EXPR
> or a MODIFY_EXPR so all cases are already handled.
OK.  I missed the comment which indicated that test only failed
during a short window of time on the mainline.

The patch is OK.

Thanks,
Jef

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-10-28  2:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-24  3:07 [PATCH] Fix PR tree-opt/17529, ICE due to *&a not being folded to a[0] Andrew Pinski
2004-10-27 17:10 ` Jeffrey A Law
2004-10-27 17:30   ` Andrew Pinski
2004-10-28  3:19     ` Jeffrey A Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).