public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/22321] New: [4.1 Regression] Wrong code with SSA dominator optimizations
@ 2005-07-06  9:32 paul dot woegerer at nsc dot com
  2005-07-06  9:39 ` [Bug c++/22321] " paul dot woegerer at nsc dot com
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: paul dot woegerer at nsc dot com @ 2005-07-06  9:32 UTC (permalink / raw)
  To: gcc-bugs

The following piece of code triggers a bug in the dominator optimizations.
With -fno-tree-dominator-opts the correct result is given back.

volatile int x;

int main ()
{
  volatile int *vip;
  vip = &x;
  const volatile int *cvip;
  cvip = vip;

  if (vip != cvip) return -1;
  return 0;
}

-- 
           Summary: [4.1 Regression] Wrong code with SSA dominator
                    optimizations
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: paul dot woegerer at nsc dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: crx-unknown-elf


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


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

* [Bug c++/22321] [4.1 Regression] Wrong code with SSA dominator optimizations
  2005-07-06  9:32 [Bug c++/22321] New: [4.1 Regression] Wrong code with SSA dominator optimizations paul dot woegerer at nsc dot com
@ 2005-07-06  9:39 ` paul dot woegerer at nsc dot com
  2005-07-06  9:54 ` falk at debian dot org
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: paul dot woegerer at nsc dot com @ 2005-07-06  9:39 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
      Known to work|                            |3.4.4


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


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

* [Bug c++/22321] [4.1 Regression] Wrong code with SSA dominator optimizations
  2005-07-06  9:32 [Bug c++/22321] New: [4.1 Regression] Wrong code with SSA dominator optimizations paul dot woegerer at nsc dot com
  2005-07-06  9:39 ` [Bug c++/22321] " paul dot woegerer at nsc dot com
@ 2005-07-06  9:54 ` falk at debian dot org
  2005-07-06 10:55 ` paul dot woegerer at nsc dot com
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: falk at debian dot org @ 2005-07-06  9:54 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From falk at debian dot org  2005-07-06 09:53 -------
It would be really helpful if you said what you expected, and what you got,
and whether you can reproduce this with another target.


-- 


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


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

* [Bug c++/22321] [4.1 Regression] Wrong code with SSA dominator optimizations
  2005-07-06  9:32 [Bug c++/22321] New: [4.1 Regression] Wrong code with SSA dominator optimizations paul dot woegerer at nsc dot com
  2005-07-06  9:39 ` [Bug c++/22321] " paul dot woegerer at nsc dot com
  2005-07-06  9:54 ` falk at debian dot org
@ 2005-07-06 10:55 ` paul dot woegerer at nsc dot com
  2005-07-06 12:11 ` falk at debian dot org
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: paul dot woegerer at nsc dot com @ 2005-07-06 10:55 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From paul dot woegerer at nsc dot com  2005-07-06 10:55 -------
Sorry i thought this trivial test case is self-explanatory.

I would expect that main returns 0.

Two pointers pointing to the same volatile int should compare
to equal (as they do when I disable dominator optimizations
with -fno-tree-dominator-opts) - no matter if one of them is
const qualified.

With -O1 (which implies -ftree-dominator-opts) main returns -1.
With -O1 -fno-tree-dominator-opts main returns 0.

Do you really think that this bug is target specific ? I've taken
a look to the tree dumps and they show that the code gets already
corruped on tree level (as you can see in the *.t21.dom1 file).


-------------------------------------------- testcase.c.t20.dce1

int main() ()
{
  const int * cvip;
  volatile int * vip;
  int D.1597;

<bb 0>:
  vip_2 = &x;
  cvip_3 = vip_2;
  if (vip_2 != cvip_3) goto <L0>; else goto <L1>;

<L0>:;
  D.1597_6 = -1;
  goto <bb 3> (<L2>);

<L1>:;
  D.1597_5 = 0;

  # D.1597_1 = PHI <D.1597_6(1), D.1597_5(2)>;
<L2>:;
  return D.1597_1;

}

-------------------------------------------- testcase.c.t21.dom1

Removing basic block 2
Merging blocks 0 and 1
int main() ()
{
  const int * cvip;
  volatile int * vip;
  int D.1597;

<bb 0>:
  vip_2 = &x;
  cvip_3 = &x;
  D.1597_6 = -1; <---------------

  # D.1597_1 = PHI <-1(0)>;
<L2>:;
  return D.1597_1;

}

-- 


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


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

* [Bug c++/22321] [4.1 Regression] Wrong code with SSA dominator optimizations
  2005-07-06  9:32 [Bug c++/22321] New: [4.1 Regression] Wrong code with SSA dominator optimizations paul dot woegerer at nsc dot com
                   ` (2 preceding siblings ...)
  2005-07-06 10:55 ` paul dot woegerer at nsc dot com
@ 2005-07-06 12:11 ` falk at debian dot org
  2005-07-06 13:10 ` pinskia at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: falk at debian dot org @ 2005-07-06 12:11 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From falk at debian dot org  2005-07-06 12:11 -------
(In reply to comment #2)

> With -O1 (which implies -ftree-dominator-opts) main returns -1.
> With -O1 -fno-tree-dominator-opts main returns 0.
> 
> Do you really think that this bug is target specific ?

I cannot repoduce this with 4.1.0 20050705 on alphaev68-unknown-linux-gnu nor
i686-pc-linux-gnu with -O1. Can you please show the output of adding -v, and
maybe try a newer snapshot?


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING


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


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

* [Bug c++/22321] [4.1 Regression] Wrong code with SSA dominator optimizations
  2005-07-06  9:32 [Bug c++/22321] New: [4.1 Regression] Wrong code with SSA dominator optimizations paul dot woegerer at nsc dot com
                   ` (3 preceding siblings ...)
  2005-07-06 12:11 ` falk at debian dot org
@ 2005-07-06 13:10 ` pinskia at gcc dot gnu dot org
  2005-07-06 13:14 ` [Bug c++/22321] [4.0/4.1 " pinskia at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-06 13:10 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-06 13:10 -------
Also I will note that this target is not in FSF's tree so there is no way to reproduce it either.

-- 


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


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

* [Bug c++/22321] [4.0/4.1 Regression] Wrong code with SSA dominator optimizations
  2005-07-06  9:32 [Bug c++/22321] New: [4.1 Regression] Wrong code with SSA dominator optimizations paul dot woegerer at nsc dot com
                   ` (4 preceding siblings ...)
  2005-07-06 13:10 ` pinskia at gcc dot gnu dot org
@ 2005-07-06 13:14 ` pinskia at gcc dot gnu dot org
  2005-07-06 13:31 ` [Bug tree-optimization/22321] " pinskia at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-06 13:14 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-06 13:14 -------
I can confirm it on the mainline and on the 4.0 branch.  The mainline you need -fno-tree-ccp to 
reproduce it.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |NEW
     Ever Confirmed|                            |1
      Known to fail|                            |4.0.0
   Last reconfirmed|0000-00-00 00:00:00         |2005-07-06 13:14:09
               date|                            |
            Summary|[4.1 Regression] Wrong code |[4.0/4.1 Regression] Wrong
                   |with SSA dominator          |code with SSA dominator
                   |optimizations               |optimizations
   Target Milestone|---                         |4.0.2


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


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

* [Bug tree-optimization/22321] [4.0/4.1 Regression] Wrong code with SSA dominator optimizations
  2005-07-06  9:32 [Bug c++/22321] New: [4.1 Regression] Wrong code with SSA dominator optimizations paul dot woegerer at nsc dot com
                   ` (5 preceding siblings ...)
  2005-07-06 13:14 ` [Bug c++/22321] [4.0/4.1 " pinskia at gcc dot gnu dot org
@ 2005-07-06 13:31 ` pinskia at gcc dot gnu dot org
  2005-07-06 13:38 ` paul dot woegerer at nsc dot com
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-06 13:31 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-06 13:31 -------
This also fails too:
volatile int x;

int main ()
{
  volatile int *vip;
  vip = &x;
  volatile int *cvip;
  cvip = vip;

  if (vip != cvip) return -1;
  return 0;
}

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mmitchel at gcc dot gnu dot
                   |                            |org, law at gcc dot gnu dot
                   |                            |org
   Target Milestone|4.0.2                       |4.0.1


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


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

* [Bug tree-optimization/22321] [4.0/4.1 Regression] Wrong code with SSA dominator optimizations
  2005-07-06  9:32 [Bug c++/22321] New: [4.1 Regression] Wrong code with SSA dominator optimizations paul dot woegerer at nsc dot com
                   ` (6 preceding siblings ...)
  2005-07-06 13:31 ` [Bug tree-optimization/22321] " pinskia at gcc dot gnu dot org
@ 2005-07-06 13:38 ` paul dot woegerer at nsc dot com
  2005-07-06 13:41 ` pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: paul dot woegerer at nsc dot com @ 2005-07-06 13:38 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From paul dot woegerer at nsc dot com  2005-07-06 13:38 -------
I used snapshot 4_1_20050508. After updating the crx-port
to the latest snapshot (4_1_20050702) the bug disappeared.

--
Sorry for inconvenience.

(Its a pity that bugzilla doesn't let me enter 4_1_20050702
 in the "Known to work" field)

-- 


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


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

* [Bug tree-optimization/22321] [4.0/4.1 Regression] Wrong code with SSA dominator optimizations
  2005-07-06  9:32 [Bug c++/22321] New: [4.1 Regression] Wrong code with SSA dominator optimizations paul dot woegerer at nsc dot com
                   ` (7 preceding siblings ...)
  2005-07-06 13:38 ` paul dot woegerer at nsc dot com
@ 2005-07-06 13:41 ` pinskia at gcc dot gnu dot org
  2005-07-06 13:48 ` paul dot woegerer at nsc dot com
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-06 13:41 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-06 13:41 -------
(In reply to comment #7)
> I used snapshot 4_1_20050508. After updating the crx-port
> to the latest snapshot (4_1_20050702) the bug disappeared.

But it is still a latent bug as I showed in comment #5, it is just harder to reproduce.

-- 


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


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

* [Bug tree-optimization/22321] [4.0/4.1 Regression] Wrong code with SSA dominator optimizations
  2005-07-06  9:32 [Bug c++/22321] New: [4.1 Regression] Wrong code with SSA dominator optimizations paul dot woegerer at nsc dot com
                   ` (8 preceding siblings ...)
  2005-07-06 13:41 ` pinskia at gcc dot gnu dot org
@ 2005-07-06 13:48 ` paul dot woegerer at nsc dot com
  2005-07-06 17:04 ` mmitchel at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: paul dot woegerer at nsc dot com @ 2005-07-06 13:48 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From paul dot woegerer at nsc dot com  2005-07-06 13:47 -------
(In reply to comment #4)
> Also I will note that this target is not in FSF's tree so there is no way to
reproduce it either.

I've already submitted the crx-port some time ago.

http://gcc.gnu.org/ml/gcc-patches/2005-04/msg02581.html

Jim Wilson agreed to review it. I'm still waiting
for feedback.

-- 


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


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

* [Bug tree-optimization/22321] [4.0/4.1 Regression] Wrong code with SSA dominator optimizations
  2005-07-06  9:32 [Bug c++/22321] New: [4.1 Regression] Wrong code with SSA dominator optimizations paul dot woegerer at nsc dot com
                   ` (9 preceding siblings ...)
  2005-07-06 13:48 ` paul dot woegerer at nsc dot com
@ 2005-07-06 17:04 ` mmitchel at gcc dot gnu dot org
  2005-07-07  7:34 ` law at redhat dot com
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-07-06 17:04 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2005-07-06 17:03 -------
Postponed until 4.0.2.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.0.1                       |4.0.2


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


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

* [Bug tree-optimization/22321] [4.0/4.1 Regression] Wrong code with SSA dominator optimizations
  2005-07-06  9:32 [Bug c++/22321] New: [4.1 Regression] Wrong code with SSA dominator optimizations paul dot woegerer at nsc dot com
                   ` (10 preceding siblings ...)
  2005-07-06 17:04 ` mmitchel at gcc dot gnu dot org
@ 2005-07-07  7:34 ` law at redhat dot com
  2005-07-09 18:01 ` [Bug middle-end/22321] [4.0/4.1 Regression] &volatile_var != &volatile_var is always true pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: law at redhat dot com @ 2005-07-07  7:34 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From law at redhat dot com  2005-07-07 07:34 -------
Subject: Re:  [4.0/4.1 Regression] Wrong code
	with SSA dominator optimizations

On Wed, 2005-07-06 at 13:31 +0000, pinskia at gcc dot gnu dot org wrote:
> ------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-06 13:31 -------
> This also fails too:
> volatile int x;
> 
> int main ()
> {
>   volatile int *vip;
>   vip = &x;
>   volatile int *cvip;
>   cvip = vip;
> 
>   if (vip != cvip) return -1;
>   return 0;
> }
This is actually a generic problem with fold and operand_equal_p.  Given
two nodes &x and &x, operand_equal_p may return false...  Which in turn
causes the conditional to be incorrectly optimized.

Jeff





-- 


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


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

* [Bug middle-end/22321] [4.0/4.1 Regression] &volatile_var != &volatile_var is always true
  2005-07-06  9:32 [Bug c++/22321] New: [4.1 Regression] Wrong code with SSA dominator optimizations paul dot woegerer at nsc dot com
                   ` (11 preceding siblings ...)
  2005-07-07  7:34 ` law at redhat dot com
@ 2005-07-09 18:01 ` pinskia at gcc dot gnu dot org
  2005-07-09 22:59 ` law at redhat dot com
  2005-07-13 17:38 ` pinskia at gcc dot gnu dot org
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-09 18:01 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-09 17:58 -------
This fails also at -O0:
volatile int x;

int main()
{
  if (&x != &x)
   abort ();
  return 0;
}

And this testcase worked in 3.4.x too so this is defintely a fold bug.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|tree-optimization           |middle-end
            Summary|[4.0/4.1 Regression] Wrong  |[4.0/4.1 Regression]
                   |code with SSA dominator     |&volatile_var !=
                   |optimizations               |&volatile_var is always true


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


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

* [Bug middle-end/22321] [4.0/4.1 Regression] &volatile_var != &volatile_var is always true
  2005-07-06  9:32 [Bug c++/22321] New: [4.1 Regression] Wrong code with SSA dominator optimizations paul dot woegerer at nsc dot com
                   ` (12 preceding siblings ...)
  2005-07-09 18:01 ` [Bug middle-end/22321] [4.0/4.1 Regression] &volatile_var != &volatile_var is always true pinskia at gcc dot gnu dot org
@ 2005-07-09 22:59 ` law at redhat dot com
  2005-07-13 17:38 ` pinskia at gcc dot gnu dot org
  14 siblings, 0 replies; 16+ messages in thread
From: law at redhat dot com @ 2005-07-09 22:59 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From law at redhat dot com  2005-07-09 21:58 -------
Subject: Re:  [4.0/4.1 Regression] &volatile_var !=
	&volatile_var is always true

On Sat, 2005-07-09 at 17:58 +0000, pinskia at gcc dot gnu dot org wrote:
> ------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-09 17:58 -------
> This fails also at -O0:
> volatile int x;
> 
> int main()
> {
>   if (&x != &x)
>    abort ();
>   return 0;
> }
> 
> And this testcase worked in 3.4.x too so this is defintely a fold bug.
It's a bug in how the folder uses operand_equal_p.  operand_equal_p is
not equivalent to a C equality test, but fold_binary is using it to
evaluate a C equality test and thus getting the wrong results.

I've got a patch ready to go, but won't get it checked in until Monday
or possibly even Tuesday depending on some personal commitments.

jeff




-- 


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


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

* [Bug middle-end/22321] [4.0/4.1 Regression] &volatile_var != &volatile_var is always true
  2005-07-06  9:32 [Bug c++/22321] New: [4.1 Regression] Wrong code with SSA dominator optimizations paul dot woegerer at nsc dot com
                   ` (13 preceding siblings ...)
  2005-07-09 22:59 ` law at redhat dot com
@ 2005-07-13 17:38 ` pinskia at gcc dot gnu dot org
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-13 17:38 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-13 17:38 -------
Fixed.

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


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


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

end of thread, other threads:[~2005-07-13 17:38 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-06  9:32 [Bug c++/22321] New: [4.1 Regression] Wrong code with SSA dominator optimizations paul dot woegerer at nsc dot com
2005-07-06  9:39 ` [Bug c++/22321] " paul dot woegerer at nsc dot com
2005-07-06  9:54 ` falk at debian dot org
2005-07-06 10:55 ` paul dot woegerer at nsc dot com
2005-07-06 12:11 ` falk at debian dot org
2005-07-06 13:10 ` pinskia at gcc dot gnu dot org
2005-07-06 13:14 ` [Bug c++/22321] [4.0/4.1 " pinskia at gcc dot gnu dot org
2005-07-06 13:31 ` [Bug tree-optimization/22321] " pinskia at gcc dot gnu dot org
2005-07-06 13:38 ` paul dot woegerer at nsc dot com
2005-07-06 13:41 ` pinskia at gcc dot gnu dot org
2005-07-06 13:48 ` paul dot woegerer at nsc dot com
2005-07-06 17:04 ` mmitchel at gcc dot gnu dot org
2005-07-07  7:34 ` law at redhat dot com
2005-07-09 18:01 ` [Bug middle-end/22321] [4.0/4.1 Regression] &volatile_var != &volatile_var is always true pinskia at gcc dot gnu dot org
2005-07-09 22:59 ` law at redhat dot com
2005-07-13 17:38 ` 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).