public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/28807] [4.2 Regression] wrong code with may_alias and structs
  2006-08-22 17:59 [Bug tree-optimization/28807] New: [4.2 Regression] wrong code with may_alias and structs pinskia at gcc dot gnu dot org
@ 2006-08-22 17:59 ` pinskia at gcc dot gnu dot org
  2006-08-22 18:19 ` dberlin at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-08-22 17:59 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |4.2.0
      Known to work|                            |4.1.2
   Target Milestone|---                         |4.2.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28807


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

* [Bug tree-optimization/28807]  New: [4.2 Regression] wrong code with may_alias and structs
@ 2006-08-22 17:59 pinskia at gcc dot gnu dot org
  2006-08-22 17:59 ` [Bug tree-optimization/28807] " pinskia at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-08-22 17:59 UTC (permalink / raw)
  To: gcc-bugs

Testcase:
#include <stdio.h>

struct S { short x; };
typedef struct S __attribute__((__may_alias__)) test;

int f() {
  int a=10;
  test *p=(test *)&a;
  test s={1};
  *p=s;
  return a;
}

int main() {
  if (f() == 10)
    __builtin_abort()
  return 0;
}

-------
Even though the struct is not the same size as int, this should still work as
the struct is marked as may_alias so we get an aliasing set of 0.


-- 
           Summary: [4.2 Regression] wrong code with may_alias and structs
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pinskia at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28807


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

* [Bug tree-optimization/28807] [4.2 Regression] wrong code with may_alias and structs
  2006-08-22 17:59 [Bug tree-optimization/28807] New: [4.2 Regression] wrong code with may_alias and structs pinskia at gcc dot gnu dot org
  2006-08-22 17:59 ` [Bug tree-optimization/28807] " pinskia at gcc dot gnu dot org
@ 2006-08-22 18:19 ` dberlin at gcc dot gnu dot org
  2006-08-22 21:49 ` pinskia at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: dberlin at gcc dot gnu dot org @ 2006-08-22 18:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from dberlin at gcc dot gnu dot org  2006-08-22 18:18 -------
Add an alias dump so we can see what things think of all this?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28807


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

* [Bug tree-optimization/28807] [4.2 Regression] wrong code with may_alias and structs
  2006-08-22 17:59 [Bug tree-optimization/28807] New: [4.2 Regression] wrong code with may_alias and structs pinskia at gcc dot gnu dot org
  2006-08-22 17:59 ` [Bug tree-optimization/28807] " pinskia at gcc dot gnu dot org
  2006-08-22 18:19 ` dberlin at gcc dot gnu dot org
@ 2006-08-22 21:49 ` pinskia at gcc dot gnu dot org
  2006-08-22 21:50 ` pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-08-22 21:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2006-08-22 21:49 -------
Better testcase which shows the problem before SRA:
struct S { short x; };
typedef struct S __attribute__((__may_alias__)) test;

int f() {
  int a=10;
  test *p=(test *)&a;
  p->x = 1;
  return a;
}

int main() {
  if (f() == 10)
    __builtin_abort();
  return 0;
}

------
I will attach the aliasing dump after this.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28807


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

* [Bug tree-optimization/28807] [4.2 Regression] wrong code with may_alias and structs
  2006-08-22 17:59 [Bug tree-optimization/28807] New: [4.2 Regression] wrong code with may_alias and structs pinskia at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2006-08-22 21:49 ` pinskia at gcc dot gnu dot org
@ 2006-08-22 21:50 ` pinskia at gcc dot gnu dot org
  2006-08-23  1:40 ` dberlin at dberlin dot org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-08-22 21:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2006-08-22 21:50 -------
Created an attachment (id=12116)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=12116&action=view)
aliasing dump

aliasing dump for the newest testcase.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28807


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

* [Bug tree-optimization/28807] [4.2 Regression] wrong code with may_alias and structs
  2006-08-22 17:59 [Bug tree-optimization/28807] New: [4.2 Regression] wrong code with may_alias and structs pinskia at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2006-08-22 21:50 ` pinskia at gcc dot gnu dot org
@ 2006-08-23  1:40 ` dberlin at dberlin dot org
  2006-08-23  8:06 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: dberlin at dberlin dot org @ 2006-08-23  1:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from dberlin at gcc dot gnu dot org  2006-08-23 01:40 -------
Subject: Re:  [4.2 Regression] wrong code with
 may_alias and structs

pinskia at gcc dot gnu dot org wrote:
> ------- Comment #3 from pinskia at gcc dot gnu dot org  2006-08-22 21:50 -------
> Created an attachment (id=12116)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=12116&action=view)
>  --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=12116&action=view)
> aliasing dump
> 
> aliasing dump for the newest testcase.
> 
> 

My guess is now that access_can_touch_variable is returning false for
the p->x store when it asks about a, so it uses the bare NMT.

This is a hard nut to crack, my *guess* is that if you just check the
alias set of the type of the access, we are going to end up claiming any
access to a structure containing a char variable is aliased.

Try it though :)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28807


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

* [Bug tree-optimization/28807] [4.2 Regression] wrong code with may_alias and structs
  2006-08-22 17:59 [Bug tree-optimization/28807] New: [4.2 Regression] wrong code with may_alias and structs pinskia at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2006-08-23  1:40 ` dberlin at dberlin dot org
@ 2006-08-23  8:06 ` pinskia at gcc dot gnu dot org
  2006-08-23  8:11 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-08-23  8:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pinskia at gcc dot gnu dot org  2006-08-23 08:06 -------
(In reply to comment #4)
> This is a hard nut to crack, my *guess* is that if you just check the
> alias set of the type of the access, we are going to end up claiming any
> access to a structure containing a char variable is aliased.
You are correct as we regress with the following testcase:
struct a
{
  char a1;
};

int *aa;

void g(int *a)
{
  aa = a;
  *a = 2;
}

int t(int i, struct a *b)
{
  g(&i);
  b->a1 = 1;
  i = 2;
  if (b->a1 != 1)
    link_failure ();
}
int main(void)
{
  struct a b;
  t(1, &b);
  return 0;
}


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28807


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

* [Bug tree-optimization/28807] [4.2 Regression] wrong code with may_alias and structs
  2006-08-22 17:59 [Bug tree-optimization/28807] New: [4.2 Regression] wrong code with may_alias and structs pinskia at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2006-08-23  8:06 ` pinskia at gcc dot gnu dot org
@ 2006-08-23  8:11 ` pinskia at gcc dot gnu dot org
  2006-08-24 15:16 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-08-23  8:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pinskia at gcc dot gnu dot org  2006-08-23 08:11 -------
This patch fixes the problem without causing the missed optimization to
happen:Index: tree-ssa-operands.c
===================================================================
--- tree-ssa-operands.c (revision 116342)
+++ tree-ssa-operands.c (working copy)
@@ -1150,7 +1150,8 @@ access_can_touch_variable (tree ref, tre
               || TREE_CODE (TREE_TYPE (base)) != UNION_TYPE)
           && !AGGREGATE_TYPE_P (TREE_TYPE (alias))
           && TREE_CODE (TREE_TYPE (alias)) != COMPLEX_TYPE
-          && !POINTER_TYPE_P (TREE_TYPE (alias)))
+          && !POINTER_TYPE_P (TREE_TYPE (alias))
+          && get_alias_set (base))
     {
 #ifdef ACCESS_DEBUGGING
       fprintf (stderr, "Access to ");


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28807


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

* [Bug tree-optimization/28807] [4.2 Regression] wrong code with may_alias and structs
  2006-08-22 17:59 [Bug tree-optimization/28807] New: [4.2 Regression] wrong code with may_alias and structs pinskia at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2006-08-23  8:11 ` pinskia at gcc dot gnu dot org
@ 2006-08-24 15:16 ` pinskia at gcc dot gnu dot org
  2006-08-24 15:19 ` patchapp at dberlin dot org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-08-24 15:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pinskia at gcc dot gnu dot org  2006-08-24 15:16 -------
Mine, all mine.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pinskia at gcc dot gnu dot
                   |dot org                     |org
                URL|                            |http://gcc.gnu.org/ml/gcc-
                   |                            |patches/2006-
                   |                            |08/msg00878.html
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
           Keywords|                            |patch
   Last reconfirmed|0000-00-00 00:00:00         |2006-08-24 15:16:34
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28807


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

* [Bug tree-optimization/28807] [4.2 Regression] wrong code with may_alias and structs
  2006-08-22 17:59 [Bug tree-optimization/28807] New: [4.2 Regression] wrong code with may_alias and structs pinskia at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2006-08-24 15:16 ` pinskia at gcc dot gnu dot org
@ 2006-08-24 15:19 ` patchapp at dberlin dot org
  2006-08-25  7:14 ` pinskia at gcc dot gnu dot org
  2006-08-25  7:14 ` pinskia at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: patchapp at dberlin dot org @ 2006-08-24 15:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from patchapp at dberlin dot org  2006-08-24 15:18 -------
Subject: Bug number PR 28807

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2006-08/msg00878.html


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28807


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

* [Bug tree-optimization/28807] [4.2 Regression] wrong code with may_alias and structs
  2006-08-22 17:59 [Bug tree-optimization/28807] New: [4.2 Regression] wrong code with may_alias and structs pinskia at gcc dot gnu dot org
                   ` (9 preceding siblings ...)
  2006-08-25  7:14 ` pinskia at gcc dot gnu dot org
@ 2006-08-25  7:14 ` pinskia at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-08-25  7:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from pinskia at gcc dot gnu dot org  2006-08-25 07:14 -------
Fixed.


------- Comment #10 from pinskia at gcc dot gnu dot org  2006-08-25 07:14 -------
Subject: Bug 28807

Author: pinskia
Date: Fri Aug 25 07:13:48 2006
New Revision: 116393

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116393
Log:
2006-08-24  Andrew Pinski  <pinskia@physics.uc.edu>

        PR tree-opt/28807
        * tree-ssa-operands.c (access_can_touch_variable): Don't say
        the access through a base which has an alias set of 0 cannot
        touch the variable.

2006-08-24  Andrew Pinski  <pinskia@physics.uc.edu>

        PR tree-opt/28807
        * gcc.c-torture/execute/mayalias-2.c: New test.
        * gcc.dg/tree-ssa/alias-13.c: New test.



Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/mayalias-2.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/alias-13.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-operands.c


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28807


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

* [Bug tree-optimization/28807] [4.2 Regression] wrong code with may_alias and structs
  2006-08-22 17:59 [Bug tree-optimization/28807] New: [4.2 Regression] wrong code with may_alias and structs pinskia at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2006-08-24 15:19 ` patchapp at dberlin dot org
@ 2006-08-25  7:14 ` pinskia at gcc dot gnu dot org
  2006-08-25  7:14 ` pinskia at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-08-25  7:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from pinskia at gcc dot gnu dot org  2006-08-25 07:14 -------
Fixed.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28807


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

end of thread, other threads:[~2006-08-25  7:14 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-22 17:59 [Bug tree-optimization/28807] New: [4.2 Regression] wrong code with may_alias and structs pinskia at gcc dot gnu dot org
2006-08-22 17:59 ` [Bug tree-optimization/28807] " pinskia at gcc dot gnu dot org
2006-08-22 18:19 ` dberlin at gcc dot gnu dot org
2006-08-22 21:49 ` pinskia at gcc dot gnu dot org
2006-08-22 21:50 ` pinskia at gcc dot gnu dot org
2006-08-23  1:40 ` dberlin at dberlin dot org
2006-08-23  8:06 ` pinskia at gcc dot gnu dot org
2006-08-23  8:11 ` pinskia at gcc dot gnu dot org
2006-08-24 15:16 ` pinskia at gcc dot gnu dot org
2006-08-24 15:19 ` patchapp at dberlin dot org
2006-08-25  7:14 ` pinskia at gcc dot gnu dot org
2006-08-25  7:14 ` pinskia at gcc dot gnu dot org

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