public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* fold_indirect_ref bogous
@ 2005-04-27 14:41 Richard Guenther
  2005-04-27 16:31 ` Jeffrey A Law
  2005-05-03 14:14 ` Jeffrey A Law
  0 siblings, 2 replies; 6+ messages in thread
From: Richard Guenther @ 2005-04-27 14:41 UTC (permalink / raw)
  To: gcc


fold_indirect_ref, called from the gimplifier happily converts

 const char *a;

...

 *(char *)&a[x] = 0;

to

 a[x] = 0;

confusing alias1 and ICEing in verify_ssa:

/net/alwazn/home/rguenth/src/gcc/cvs/gcc-4.1/gcc/testsuite/gcc.c-torture/execute/20031215-1.c:11:
error: Statement makes a memory store, but has no V_MAY_DEFS nor
V_MUST_DEFS
#   VUSE <ao_1>;
ao.ch[D.1242_5] = 0;
/net/alwazn/home/rguenth/src/gcc/cvs/gcc-4.1/gcc/testsuite/gcc.c-torture/execute/20031215-1.c:11:
internal compiler error: verify_ssa failed.

happens only for patched gcc where C frontend and fold happen to
produce .02.original:

;; Function test1 (test1)
;; enabled by -tree-original


{
  if (ao.ch[ao.l] != 0)
    {
      *(char *) &ao.ch[(unsigned int) ao.l] = 0;
    }
}

then, generic is already wrong:

test1 ()
{
  int D.1240;
  char D.1241;
  unsigned int D.1242;

  D.1240 = ao.l;
  D.1241 = ao.ch[D.1240];
  if (D.1241 != 0)
    {
      D.1240 = ao.l;
      D.1242 = (unsigned int) D.1240;
      ao.ch[D.1242] = 0;
    }

(not the missing cast).


something like the following patch fixes this.

Richard.


Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.572
diff -c -3 -p -r1.572 fold-const.c
*** fold-const.c	26 Apr 2005 16:35:10 -0000	1.572
--- fold-const.c	27 Apr 2005 14:15:10 -0000
*************** fold_indirect_ref_1 (tree t)
*** 11322,11328 ****
    tree sub = t;
    tree subtype;

!   STRIP_NOPS (sub);
    subtype = TREE_TYPE (sub);
    if (!POINTER_TYPE_P (subtype))
      return NULL_TREE;
--- 11315,11321 ----
    tree sub = t;
    tree subtype;

!   STRIP_TYPE_NOPS (sub);
    subtype = TREE_TYPE (sub);
    if (!POINTER_TYPE_P (subtype))
      return NULL_TREE;

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

* Re: fold_indirect_ref bogous
  2005-04-27 14:41 fold_indirect_ref bogous Richard Guenther
@ 2005-04-27 16:31 ` Jeffrey A Law
  2005-04-27 17:39   ` Richard Guenther
  2005-05-03 14:14 ` Jeffrey A Law
  1 sibling, 1 reply; 6+ messages in thread
From: Jeffrey A Law @ 2005-04-27 16:31 UTC (permalink / raw)
  To: Richard Guenther; +Cc: gcc

On Wed, 2005-04-27 at 16:19 +0200, Richard Guenther wrote:
> fold_indirect_ref, called from the gimplifier happily converts
> 
>  const char *a;
> 
> ...
> 
>  *(char *)&a[x] = 0;
> 
> to
> 
>  a[x] = 0;
> 
> confusing alias1 and ICEing in verify_ssa:
> 
> /net/alwazn/home/rguenth/src/gcc/cvs/gcc-4.1/gcc/testsuite/gcc.c-torture/execute/20031215-1.c:11:
> error: Statement makes a memory store, but has no V_MAY_DEFS nor
> V_MUST_DEFS
> #   VUSE <ao_1>;
> ao.ch[D.1242_5] = 0;
> /net/alwazn/home/rguenth/src/gcc/cvs/gcc-4.1/gcc/testsuite/gcc.c-torture/execute/20031215-1.c:11:
> internal compiler error: verify_ssa failed.
> 
> happens only for patched gcc where C frontend and fold happen to
> produce .02.original:
> 
> ;; Function test1 (test1)
> ;; enabled by -tree-original
> 
> 
> {
>   if (ao.ch[ao.l] != 0)
>     {
>       *(char *) &ao.ch[(unsigned int) ao.l] = 0;
>     }
> }
> 
> then, generic is already wrong:
> 
> test1 ()
> {
>   int D.1240;
>   char D.1241;
>   unsigned int D.1242;
> 
>   D.1240 = ao.l;
>   D.1241 = ao.ch[D.1240];
>   if (D.1241 != 0)
>     {
>       D.1240 = ao.l;
>       D.1242 = (unsigned int) D.1240;
>       ao.ch[D.1242] = 0;
>     }
> 
> (not the missing cast).
> 
> 
> something like the following patch fixes this.
How ironic.  I ran into a similar problem with the fold-after-TER
patches.  I just killed the STRIP_NOPS call, but using STRIP_TYPE_NOPS
might be a better solution.

jeff


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

* Re: fold_indirect_ref bogous
  2005-04-27 16:31 ` Jeffrey A Law
@ 2005-04-27 17:39   ` Richard Guenther
  2005-05-03  5:10     ` Jeffrey A Law
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Guenther @ 2005-04-27 17:39 UTC (permalink / raw)
  To: law; +Cc: gcc

Jeffrey A Law wrote:
> On Wed, 2005-04-27 at 16:19 +0200, Richard Guenther wrote:
> 
>>fold_indirect_ref, called from the gimplifier happily converts
>>
>> const char *a;
>>
>>...
>>
>> *(char *)&a[x] = 0;
>>
>>to
>>
>> a[x] = 0;
>>
>>confusing alias1 and ICEing in verify_ssa:
>>
>>/net/alwazn/home/rguenth/src/gcc/cvs/gcc-4.1/gcc/testsuite/gcc.c-torture/execute/20031215-1.c:11:
>>error: Statement makes a memory store, but has no V_MAY_DEFS nor
>>V_MUST_DEFS
>>#   VUSE <ao_1>;
>>ao.ch[D.1242_5] = 0;
>>/net/alwazn/home/rguenth/src/gcc/cvs/gcc-4.1/gcc/testsuite/gcc.c-torture/execute/20031215-1.c:11:
>>internal compiler error: verify_ssa failed.
>>
>>happens only for patched gcc where C frontend and fold happen to
>>produce .02.original:
>>
>>;; Function test1 (test1)
>>;; enabled by -tree-original
>>
>>
>>{
>>  if (ao.ch[ao.l] != 0)
>>    {
>>      *(char *) &ao.ch[(unsigned int) ao.l] = 0;
>>    }
>>}
>>
>>then, generic is already wrong:
>>
>>test1 ()
>>{
>>  int D.1240;
>>  char D.1241;
>>  unsigned int D.1242;
>>
>>  D.1240 = ao.l;
>>  D.1241 = ao.ch[D.1240];
>>  if (D.1241 != 0)
>>    {
>>      D.1240 = ao.l;
>>      D.1242 = (unsigned int) D.1240;
>>      ao.ch[D.1242] = 0;
>>    }
>>
>>(not the missing cast).
>>
>>
>>something like the following patch fixes this.
> 
> How ironic.  I ran into a similar problem with the fold-after-TER
> patches.  I just killed the STRIP_NOPS call, but using STRIP_TYPE_NOPS
> might be a better solution.

So is the patch ok for mainline?  It happened to be in during a
bootstrap and regtest on i686-linux for c only.

Richard.

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

* Re: fold_indirect_ref bogous
  2005-04-27 17:39   ` Richard Guenther
@ 2005-05-03  5:10     ` Jeffrey A Law
  0 siblings, 0 replies; 6+ messages in thread
From: Jeffrey A Law @ 2005-05-03  5:10 UTC (permalink / raw)
  To: Richard Guenther; +Cc: gcc

On Wed, 2005-04-27 at 19:14 +0200, Richard Guenther wrote:
> Jeffrey A Law wrote:
> > On Wed, 2005-04-27 at 16:19 +0200, Richard Guenther wrote:
> > 
> >>fold_indirect_ref, called from the gimplifier happily converts
> >>
> >> const char *a;
> >>
> >>...
> >>
> >> *(char *)&a[x] = 0;
> >>
> >>to
> >>
> >> a[x] = 0;
> >>
> >>confusing alias1 and ICEing in verify_ssa:
> >>
> >>/net/alwazn/home/rguenth/src/gcc/cvs/gcc-4.1/gcc/testsuite/gcc.c-torture/execute/20031215-1.c:11:
> >>error: Statement makes a memory store, but has no V_MAY_DEFS nor
> >>V_MUST_DEFS
> >>#   VUSE <ao_1>;
> >>ao.ch[D.1242_5] = 0;
> >>/net/alwazn/home/rguenth/src/gcc/cvs/gcc-4.1/gcc/testsuite/gcc.c-torture/execute/20031215-1.c:11:
> >>internal compiler error: verify_ssa failed.
> >>
> >>happens only for patched gcc where C frontend and fold happen to
> >>produce .02.original:
> >>
> >>;; Function test1 (test1)
> >>;; enabled by -tree-original
> >>
> >>
> >>{
> >>  if (ao.ch[ao.l] != 0)
> >>    {
> >>      *(char *) &ao.ch[(unsigned int) ao.l] = 0;
> >>    }
> >>}
> >>
> >>then, generic is already wrong:
> >>
> >>test1 ()
> >>{
> >>  int D.1240;
> >>  char D.1241;
> >>  unsigned int D.1242;
> >>
> >>  D.1240 = ao.l;
> >>  D.1241 = ao.ch[D.1240];
> >>  if (D.1241 != 0)
> >>    {
> >>      D.1240 = ao.l;
> >>      D.1242 = (unsigned int) D.1240;
> >>      ao.ch[D.1242] = 0;
> >>    }
> >>
> >>(not the missing cast).
> >>
> >>
> >>something like the following patch fixes this.
> > 
> > How ironic.  I ran into a similar problem with the fold-after-TER
> > patches.  I just killed the STRIP_NOPS call, but using STRIP_TYPE_NOPS
> > might be a better solution.
> 
> So is the patch ok for mainline?  It happened to be in during a
> bootstrap and regtest on i686-linux for c only.
I just ran a full bootstrap and regrest using STRIP_TYPE_NOPS + the fold
after TER patch.  I'm going to be checking in the STRIP_TYPE_NOPS change
shortly...

jeff


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

* Re: fold_indirect_ref bogous
  2005-04-27 14:41 fold_indirect_ref bogous Richard Guenther
  2005-04-27 16:31 ` Jeffrey A Law
@ 2005-05-03 14:14 ` Jeffrey A Law
  2005-05-10 15:56   ` Richard Guenther
  1 sibling, 1 reply; 6+ messages in thread
From: Jeffrey A Law @ 2005-05-03 14:14 UTC (permalink / raw)
  To: Richard Guenther; +Cc: gcc-patches, gcc

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

On Wed, 2005-04-27 at 16:19 +0200, Richard Guenther wrote:
> fold_indirect_ref, called from the gimplifier happily converts
> 
>  const char *a;
> 
> ...
> 
>  *(char *)&a[x] = 0;
> 
> to
> 
>  a[x] = 0;
> 
> confusing alias1 and ICEing in verify_ssa:
> 
> /net/alwazn/home/rguenth/src/gcc/cvs/gcc-4.1/gcc/testsuite/gcc.c-torture/execute/20031215-1.c:11:
> error: Statement makes a memory store, but has no V_MAY_DEFS nor
> V_MUST_DEFS
> #   VUSE <ao_1>;
> ao.ch[D.1242_5] = 0;
> /net/alwazn/home/rguenth/src/gcc/cvs/gcc-4.1/gcc/testsuite/gcc.c-torture/execute/20031215-1.c:11:
> internal compiler error: verify_ssa failed.
> 
> happens only for patched gcc where C frontend and fold happen to
> produce .02.original:
> 
> ;; Function test1 (test1)
> ;; enabled by -tree-original
> 
> 
> {
>   if (ao.ch[ao.l] != 0)
>     {
>       *(char *) &ao.ch[(unsigned int) ao.l] = 0;
>     }
> }
> 
> then, generic is already wrong:
> 
> test1 ()
> {
>   int D.1240;
>   char D.1241;
>   unsigned int D.1242;
> 
>   D.1240 = ao.l;
>   D.1241 = ao.ch[D.1240];
>   if (D.1241 != 0)
>     {
>       D.1240 = ao.l;
>       D.1242 = (unsigned int) D.1240;
>       ao.ch[D.1242] = 0;
>     }
> 
> (note the missing cast).
> 
> 
> something like the following patch fixes this.
Right.  Given that I'd seen similar problems with some unrelated
changes of mine, I went ahead and put your patch through the usual
bootstrap and regression tests on my i686 box.

Installed.





[-- Attachment #2: PPP --]
[-- Type: text/plain, Size: 1019 bytes --]

	* tree-ssa-ccp.c (maybe_fold_stmt_indirect): Use STRIP_TYPE_NOPS
	rather than STRIP_NOPS.

Index: tree-ssa-ccp.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-ccp.c,v
retrieving revision 2.68
diff -c -p -r2.68 tree-ssa-ccp.c
*** tree-ssa-ccp.c	3 May 2005 12:19:42 -0000	2.68
--- tree-ssa-ccp.c	3 May 2005 14:11:10 -0000
*************** maybe_fold_stmt_indirect (tree expr, tre
*** 1585,1591 ****
       substitutions.  Fold that down to one.  Remove NON_LVALUE_EXPRs that
       are sometimes added.  */
    base = fold (base);
!   STRIP_NOPS (base);
    TREE_OPERAND (expr, 0) = base;
  
    /* One possibility is that the address reduces to a string constant.  */
--- 1585,1591 ----
       substitutions.  Fold that down to one.  Remove NON_LVALUE_EXPRs that
       are sometimes added.  */
    base = fold (base);
!   STRIP_TYPE_NOPS (base);
    TREE_OPERAND (expr, 0) = base;
  
    /* One possibility is that the address reduces to a string constant.  */

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

* Re: fold_indirect_ref bogous
  2005-05-03 14:14 ` Jeffrey A Law
@ 2005-05-10 15:56   ` Richard Guenther
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Guenther @ 2005-05-10 15:56 UTC (permalink / raw)
  To: Jeffrey A Law; +Cc: gcc-patches, gcc

On Tue, 3 May 2005, Jeffrey A Law wrote:

> On Wed, 2005-04-27 at 16:19 +0200, Richard Guenther wrote:
> > fold_indirect_ref, called from the gimplifier happily converts
   ^^^^^^^^^^^^^^^^^^

> > something like the following patch fixes this.
> Right.  Given that I'd seen similar problems with some unrelated
> changes of mine, I went ahead and put your patch through the usual
> bootstrap and regression tests on my i686 box.
>
> Installed.

You didn't ;)  You fixed
tree-ssa-ccp.c:maybe_fold_stmt_indirect, not
fold-const.c:fold_indirect_ref_1 !  The latter is causing the
failure I'm running into.

Richard.

--
Richard Guenther <richard dot guenther at uni-tuebingen dot de>
WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/


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

end of thread, other threads:[~2005-05-10 15:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-27 14:41 fold_indirect_ref bogous Richard Guenther
2005-04-27 16:31 ` Jeffrey A Law
2005-04-27 17:39   ` Richard Guenther
2005-05-03  5:10     ` Jeffrey A Law
2005-05-03 14:14 ` Jeffrey A Law
2005-05-10 15:56   ` Richard Guenther

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).