public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/14272] New: miscompilation of __exchange_and_add (atomicity.h)
@ 2004-02-24 13:35 ehrhardt at mathematik dot uni-ulm dot de
  2004-02-24 14:26 ` [Bug optimization/14272] [tree-ssa] " pinskia at gcc dot gnu dot org
                   ` (20 more replies)
  0 siblings, 21 replies; 23+ messages in thread
From: ehrhardt at mathematik dot uni-ulm dot de @ 2004-02-24 13:35 UTC (permalink / raw)
  To: gcc-bugs

The following piece of code (destilled from atomicity.h in
libstdc++-v3) is miscompiled by tree-ssa with -O2 on a sparc-sun-solaris2.9
platform (probably arch independant). The code outputs BUG!!! where
it clearly shouldn't. This works with C and C++.

====================== cut =============================
extern int printf (const char *, ...);

int __attribute__ ((__noinline__))
__exchange_and_add (volatile int* __mem, int __val)
{
  int __result, __tmp;
  __result = *__mem;
  *__mem += __val;
  return __result;
}

int data = 0;

int main ()
{
	if (__exchange_and_add (&data, 1) != 0) {
		printf ("BUG!!!\n");
	}
	return 0;
}
====================== cut =============================

The consequences in the context of libstdc++ on sparc-sun-solaris are
that std::cout and friends are never initialized, i.e. not even a hello
world program runs. Note that the volatile keyword is crucial, removing
it makes the bug go away. The wrong code first appears in .t35.optimized.

    regards   Christian

-- 
           Summary: miscompilation of __exchange_and_add (atomicity.h)
           Product: gcc
           Version: tree-ssa
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: critical
          Priority: P1
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ehrhardt at mathematik dot uni-ulm dot de
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug optimization/14272] [tree-ssa] miscompilation of __exchange_and_add (atomicity.h)
  2004-02-24 13:35 [Bug c/14272] New: miscompilation of __exchange_and_add (atomicity.h) ehrhardt at mathematik dot uni-ulm dot de
@ 2004-02-24 14:26 ` pinskia at gcc dot gnu dot org
  2004-02-24 14:48 ` ehrhardt at mathematik dot uni-ulm dot de
                   ` (19 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-02-24 14:26 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-02-24 14:26 -------
Confirmed.  The problem is caused by "out of SSA" pass.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
          Component|c                           |optimization
     Ever Confirmed|                            |1
      Known to fail|                            |tree-ssa
   Last reconfirmed|0000-00-00 00:00:00         |2004-02-24 14:26:13
               date|                            |
            Summary|miscompilation of           |[tree-ssa] miscompilation of
                   |__exchange_and_add          |__exchange_and_add
                   |(atomicity.h)               |(atomicity.h)
   Target Milestone|---                         |tree-ssa


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


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

* [Bug optimization/14272] [tree-ssa] miscompilation of __exchange_and_add (atomicity.h)
  2004-02-24 13:35 [Bug c/14272] New: miscompilation of __exchange_and_add (atomicity.h) ehrhardt at mathematik dot uni-ulm dot de
  2004-02-24 14:26 ` [Bug optimization/14272] [tree-ssa] " pinskia at gcc dot gnu dot org
@ 2004-02-24 14:48 ` ehrhardt at mathematik dot uni-ulm dot de
  2004-02-25 12:40 ` steven at gcc dot gnu dot org
                   ` (18 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: ehrhardt at mathematik dot uni-ulm dot de @ 2004-02-24 14:48 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From ehrhardt at mathematik dot uni-ulm dot de  2004-02-24 14:48 -------
Passing -fno-tree-ter makes the bug go away. Andrew: According to
the ChangeLog you added the ter code. Can you have a look at this, please?

   regards  Christian



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amacleod at redhat dot com


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


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

* [Bug optimization/14272] [tree-ssa] miscompilation of __exchange_and_add (atomicity.h)
  2004-02-24 13:35 [Bug c/14272] New: miscompilation of __exchange_and_add (atomicity.h) ehrhardt at mathematik dot uni-ulm dot de
  2004-02-24 14:26 ` [Bug optimization/14272] [tree-ssa] " pinskia at gcc dot gnu dot org
  2004-02-24 14:48 ` ehrhardt at mathematik dot uni-ulm dot de
@ 2004-02-25 12:40 ` steven at gcc dot gnu dot org
  2004-02-25 13:32 ` steven at gcc dot gnu dot org
                   ` (17 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: steven at gcc dot gnu dot org @ 2004-02-25 12:40 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From steven at gcc dot gnu dot org  2004-02-25 12:39 -------
This also happens on ix86, and already at -O, obviously. 

-- 


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


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

* [Bug optimization/14272] [tree-ssa] miscompilation of __exchange_and_add (atomicity.h)
  2004-02-24 13:35 [Bug c/14272] New: miscompilation of __exchange_and_add (atomicity.h) ehrhardt at mathematik dot uni-ulm dot de
                   ` (2 preceding siblings ...)
  2004-02-25 12:40 ` steven at gcc dot gnu dot org
@ 2004-02-25 13:32 ` steven at gcc dot gnu dot org
  2004-02-25 13:43 ` steven at gcc dot gnu dot org
                   ` (16 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: steven at gcc dot gnu dot org @ 2004-02-25 13:32 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From steven at gcc dot gnu dot org  2004-02-25 13:32 -------
This is a bug in the "How can this ever have worked" class. 
 
Here's the .optimized tree dump: 
---------------------------------------------------------- 
;; Function int __exchange_and_add(volatile int*, int) 
(_Z18__exchange_and_addPVii) 
 
 
CFG Statistics for int __exchange_and_add(volatile int*, int) 
 
--------------------------------------------------------- 
                                Number of        Memory 
                                instances         used  
--------------------------------------------------------- 
Basic blocks                              1         92b 
Edges                                     1         40b 
Basic block annotations                   1         20b 
--------------------------------------------------------- 
Total memory used by CFG data                      152b 
--------------------------------------------------------- 
 
Coalesced label blocks: 0 (Max so far: 0) 
 
int __exchange_and_add(volatile int*, int) (__mem, __val) 
{ 
  int __tmp; 
  int __result; 
  int T.1; 
  volatile int T.0; 
 
  # BLOCK 0 
  # PRED: ENTRY [100.0%]  (fallthru,exec) 
  __result_2 = *__mem_1; 
  T.0_3 = *__mem_1; 
  T.1_5 = T.0_3 + __val_4; 
  *__mem_1 = T.1_5; 
  return __result_2; 
  # SUCC: EXIT [100.0%]  
 
} 
 
 
 
Partition map  
 
 
After Coalescing: 
 
Partition map  
 
Partition 0 (__mem_1 - 1 ) 
Partition 1 (__result_2 - 2 ) 
Partition 2 (T.0_3 - 3 ) 
Partition 3 (__val_4 - 4 ) 
Partition 4 (T.1_5 - 5 ) 
Partition 5 (<retval>_6 - 6 ) 
 
 
Replacing Expressions 
__result_2 replace with --> *__mem_1 
T.0_3 replace with --> *__mem_1 
T.1_5 replace with --> T.0_3 + __val_4 
 
<retval>_6  --> <retval> 
T.1_5  --> T.1 
__val_4  --> __val 
T.0_3  --> T.0 
__result_2  --> __result 
__mem_1  --> __mem 
After Root variable replacement: 
 
Partition map  
 
Partition 0 (__mem - 1 ) 
Partition 1 (__result - 2 ) 
Partition 2 (T.0 - 3 ) 
Partition 3 (__val - 4 ) 
Partition 4 (T.1 - 5 ) 
Partition 5 (<retval> - 6 ) 
 
 
CFG Statistics for int __exchange_and_add(volatile int*, int) 
 
--------------------------------------------------------- 
                                Number of        Memory 
                                instances         used  
--------------------------------------------------------- 
Basic blocks                              1         92b 
Edges                                     1         40b 
Basic block annotations                   1         20b 
--------------------------------------------------------- 
Total memory used by CFG data                      152b 
--------------------------------------------------------- 
 
Coalesced label blocks: 0 (Max so far: 0) 
 
int __exchange_and_add(volatile int*, int) (__mem, __val) 
{ 
  int __tmp; 
  int __result; 
  int T.1; 
  volatile int T.0; 
 
  # BLOCK 0 
  # PRED: ENTRY [100.0%]  (fallthru,exec) 
  *__mem = *__mem + __val; 
  return *__mem; 
  # SUCC: EXIT [100.0%]  
 
} 
 
 
int __exchange_and_add(volatile int*, int) (__mem, __val) 
{ 
  int __tmp; 
  int __result; 
  int T.1; 
  volatile int T.0; 
 
  # BLOCK 0 
  # PRED: ENTRY [100.0%]  (fallthru,exec) 
  *__mem<D1463> = *__mem<D1463> + __val<D1464>; 
  return *__mem<D1463>; 
  # SUCC: EXIT [100.0%]  
 
} 
---------------------------------------------------------- 
 
Look how the original function returns *__mem with the value 
that it enters the function with, and the second returns with 
*__mem + __val:  *__mem is redefined between the point of the 
load to the function result and the return statement. 
 
This is a really nasty bug... 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dnovillo at redhat dot com
   Last reconfirmed|2004-02-24 14:26:13         |2004-02-25 13:32:06
               date|                            |


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


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

* [Bug optimization/14272] [tree-ssa] miscompilation of __exchange_and_add (atomicity.h)
  2004-02-24 13:35 [Bug c/14272] New: miscompilation of __exchange_and_add (atomicity.h) ehrhardt at mathematik dot uni-ulm dot de
                   ` (3 preceding siblings ...)
  2004-02-25 13:32 ` steven at gcc dot gnu dot org
@ 2004-02-25 13:43 ` steven at gcc dot gnu dot org
  2004-02-25 14:02   ` Christian Ehrhardt
  2004-02-25 14:02 ` ehrhardt at mathematik dot uni-ulm dot de
                   ` (15 subsequent siblings)
  20 siblings, 1 reply; 23+ messages in thread
From: steven at gcc dot gnu dot org @ 2004-02-25 13:43 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From steven at gcc dot gnu dot org  2004-02-25 13:43 -------
This is not _really_ a TER problem, but a problem with volatiles and aliasing: 
 
*************** 
*** 17,34 **** 
 
  Coalesced label blocks: 0 (Max so far: 0) 
 
! int __exchange_and_add(volatile int*, int) (__mem, __val) 
  { 
    int __tmp; 
    int __result; 
    int T.1; 
!   volatile int T.0; 
 
    # BLOCK 0 
    # PRED: ENTRY [100.0%]  (fallthru,exec) 
    __result_2 = *__mem_1; 
!   T.0_3 = *__mem_1; 
!   T.1_5 = T.0_3 + __val_4; 
    *__mem_1 = T.1_5; 
    return __result_2; 
    # SUCC: EXIT [100.0%] 
--- 17,35 ---- 
 
  Coalesced label blocks: 0 (Max so far: 0) 
 
! int __exchange_and_add(int*, int) (__mem, __val) 
  { 
    int __tmp; 
    int __result; 
    int T.1; 
!   int T.0; 
 
    # BLOCK 0 
    # PRED: ENTRY [100.0%]  (fallthru,exec) 
+   #   VUSE <TMT.2_7>; 
    __result_2 = *__mem_1; 
!   T.1_5 = __result_2 + __val_4; 
!   #   TMT.2_8 = VDEF <TMT.2_7>; 
    *__mem_1 = T.1_5; 
    return __result_2; 
    # SUCC: EXIT [100.0%] 
 
Note the missing VUSE in the dump where __mem is volatile. 
 

-- 


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


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

* Re: [Bug optimization/14272] [tree-ssa] miscompilation of __exchange_and_add (atomicity.h)
  2004-02-25 13:43 ` steven at gcc dot gnu dot org
@ 2004-02-25 14:02   ` Christian Ehrhardt
  0 siblings, 0 replies; 23+ messages in thread
From: Christian Ehrhardt @ 2004-02-25 14:02 UTC (permalink / raw)
  To: steven at gcc dot gnu dot org; +Cc: gcc-bugs

On Wed, Feb 25, 2004 at 01:43:17PM -0000, steven at gcc dot gnu dot org wrote:
> Note the missing VUSE in the dump where __mem is volatile. 

Yes, but looking at get_expr_operands it seems intentional that 
no VUSE is created for a volatile pointer dereference. get_expr_operands
instead sets ann->has_volatile_ops on the statement. I came to the
conclusion that TER should take this flag into account in addition to
VDEFs/VUSEs when killing expressions. I may be totally wrong though.

    regards   Christian

-- 
THAT'S ALL FOLKS!


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

* [Bug optimization/14272] [tree-ssa] miscompilation of __exchange_and_add (atomicity.h)
  2004-02-24 13:35 [Bug c/14272] New: miscompilation of __exchange_and_add (atomicity.h) ehrhardt at mathematik dot uni-ulm dot de
                   ` (4 preceding siblings ...)
  2004-02-25 13:43 ` steven at gcc dot gnu dot org
@ 2004-02-25 14:02 ` ehrhardt at mathematik dot uni-ulm dot de
  2004-02-25 14:06 ` amacleod at redhat dot com
                   ` (14 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: ehrhardt at mathematik dot uni-ulm dot de @ 2004-02-25 14:02 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From ehrhardt at mathematik dot uni-ulm dot de  2004-02-25 14:02 -------
Subject: Re:  [tree-ssa] miscompilation of __exchange_and_add (atomicity.h)

On Wed, Feb 25, 2004 at 01:43:17PM -0000, steven at gcc dot gnu dot org wrote:
> Note the missing VUSE in the dump where __mem is volatile. 

Yes, but looking at get_expr_operands it seems intentional that 
no VUSE is created for a volatile pointer dereference. get_expr_operands
instead sets ann->has_volatile_ops on the statement. I came to the
conclusion that TER should take this flag into account in addition to
VDEFs/VUSEs when killing expressions. I may be totally wrong though.

    regards   Christian



-- 


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


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

* [Bug optimization/14272] [tree-ssa] miscompilation of __exchange_and_add (atomicity.h)
  2004-02-24 13:35 [Bug c/14272] New: miscompilation of __exchange_and_add (atomicity.h) ehrhardt at mathematik dot uni-ulm dot de
                   ` (5 preceding siblings ...)
  2004-02-25 14:02 ` ehrhardt at mathematik dot uni-ulm dot de
@ 2004-02-25 14:06 ` amacleod at redhat dot com
  2004-02-25 14:08 ` dnovillo at redhat dot com
                   ` (13 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: amacleod at redhat dot com @ 2004-02-25 14:06 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From amacleod at redhat dot com  2004-02-25 14:06 -------
Hmm.

__exchange_and_add (__mem, __val)
{
  int __tmp;
  int __result;
  int T.1;
  int T.0;

  # BLOCK 0
  # PRED: ENTRY [100.0%]  (fallthru,exec)
  __result_2 = *__mem_1;
  T.0_3 = *__mem_1;
  T.1_5 = T.0_3 + __val_4;
  *__mem_1 = T.1_5;
  return __result_2;
  # SUCC: EXIT [100.0%]

}

Since there are dereferences to memory and a store to memory here, ought there
not be a virtual operand of some sort to prevent the movement of the
dereferences past the store?

Diego?  Its like this right from the very beginning...

Thats why TER is doing the replacement.. no virtual operands mean no side
effects....

Andrew

-- 


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


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

* [Bug optimization/14272] [tree-ssa] miscompilation of __exchange_and_add (atomicity.h)
  2004-02-24 13:35 [Bug c/14272] New: miscompilation of __exchange_and_add (atomicity.h) ehrhardt at mathematik dot uni-ulm dot de
                   ` (6 preceding siblings ...)
  2004-02-25 14:06 ` amacleod at redhat dot com
@ 2004-02-25 14:08 ` dnovillo at redhat dot com
  2004-02-25 18:06 ` dnovillo at redhat dot com
                   ` (12 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: dnovillo at redhat dot com @ 2004-02-25 14:08 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From dnovillo at redhat dot com  2004-02-25 14:08 -------
Subject: Re:  [tree-ssa] miscompilation of
	__exchange_and_add (atomicity.h)

On Wed, 2004-02-25 at 09:06, amacleod at redhat dot com wrote:

> Diego?  Its like this right from the very beginning...
> 
> Thats why TER is doing the replacement.. no virtual operands mean no side
> effects....
> 
Yes.  TER is unlikely to be at fault here.  It should be relying on
whatever dataflow info we give it.  It should not be special casing
volatile.  I'll take a look today.


Diego.



-- 


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


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

* [Bug optimization/14272] [tree-ssa] miscompilation of __exchange_and_add (atomicity.h)
  2004-02-24 13:35 [Bug c/14272] New: miscompilation of __exchange_and_add (atomicity.h) ehrhardt at mathematik dot uni-ulm dot de
                   ` (7 preceding siblings ...)
  2004-02-25 14:08 ` dnovillo at redhat dot com
@ 2004-02-25 18:06 ` dnovillo at redhat dot com
  2004-02-25 18:20 ` amacleod at redhat dot com
                   ` (11 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: dnovillo at redhat dot com @ 2004-02-25 18:06 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From dnovillo at redhat dot com  2004-02-25 18:06 -------
Subject: Re:  [tree-ssa] miscompilation of
	__exchange_and_add (atomicity.h)

On Wed, 2004-02-25 at 09:06, amacleod at redhat dot com wrote:
> ------- Additional Comments From amacleod at redhat dot com  2004-02-25 14:06 -------
> Hmm.
> 
> __exchange_and_add (__mem, __val)
> {
>   int __tmp;
>   int __result;
>   int T.1;
>   int T.0;
> 
>   # BLOCK 0
>   # PRED: ENTRY [100.0%]  (fallthru,exec)
>   __result_2 = *__mem_1;
>   T.0_3 = *__mem_1;
>   T.1_5 = T.0_3 + __val_4;
>   *__mem_1 = T.1_5;
>   return __result_2;
>   # SUCC: EXIT [100.0%]
> 
> }
> 
> Since there are dereferences to memory and a store to memory here, ought there
> not be a virtual operand of some sort to prevent the movement of the
> dereferences past the store?
> 
I had missed the fact that those statements are examining volatile
storage.  It looks like TER was not using all the data flow
information.  We don't add operands to volatile variables, we mark the
statement with 'has_volatile_ops'.  This is to make passes ignore them.

We *could* add operands, but it would be a waste of space because the
passes would again have to check for volatility.  An alternative to
this, would involve having special virtual operands for volatile
variables or have the SSA renamer give them a special version number
(like zero).

But it always involves the optimizers checking for these markers, so it
seems easiest to just mark the statement as having volatile ops.

Fixed with this.  Andrew, am I missing anything else?  This seemed to be
the only spot where TER looked at statements.


$ cvs diff -dcp tree-ssa.c
Index: tree-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa.c,v
retrieving revision 1.1.4.205
diff -d -c -p -r1.1.4.205 tree-ssa.c
*** tree-ssa.c  25 Feb 2004 03:22:47 -0000      1.1.4.205
--- tree-ssa.c  25 Feb 2004 18:05:26 -0000
*************** find_replaceable_in_bb (temp_expr_table_
*** 2390,2395 ****
--- 2390,2399 ----
        stmt = bsi_stmt (bsi);
        ann = stmt_ann (stmt);

+       /* If the statement has volatile operands, it can be replaced.  */
+       if (ann->has_volatile_ops)
+       continue;
+
        /* Determine if this stmt finishes an existing expression.  */
        uses = USE_OPS (ann);
        num = NUM_USES (uses);




-- 


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


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

* [Bug optimization/14272] [tree-ssa] miscompilation of __exchange_and_add (atomicity.h)
  2004-02-24 13:35 [Bug c/14272] New: miscompilation of __exchange_and_add (atomicity.h) ehrhardt at mathematik dot uni-ulm dot de
                   ` (8 preceding siblings ...)
  2004-02-25 18:06 ` dnovillo at redhat dot com
@ 2004-02-25 18:20 ` amacleod at redhat dot com
  2004-02-25 19:53 ` dnovillo at redhat dot com
                   ` (10 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: amacleod at redhat dot com @ 2004-02-25 18:20 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From amacleod at redhat dot com  2004-02-25 18:20 -------
Err, did you try that patch on a testsuite run?

It seems to me that you still need to look through the operands and kill any
active partition experssions which are dependent on the uses and defs. Ie, you
wouldn't make anything replaceable, but you do need to remove things from the
current search list.

If there is anything else in the stmt which causes a virtual def, you wont be
killing any virtual dependancies either by continuing.

At the very least it will probably slow things downa  hair to not remove things
from the list when you could have.

Andrew

-- 


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


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

* [Bug optimization/14272] [tree-ssa] miscompilation of __exchange_and_add (atomicity.h)
  2004-02-24 13:35 [Bug c/14272] New: miscompilation of __exchange_and_add (atomicity.h) ehrhardt at mathematik dot uni-ulm dot de
                   ` (9 preceding siblings ...)
  2004-02-25 18:20 ` amacleod at redhat dot com
@ 2004-02-25 19:53 ` dnovillo at redhat dot com
  2004-02-25 19:54 ` dnovillo at redhat dot com
                   ` (9 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: dnovillo at redhat dot com @ 2004-02-25 19:53 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From dnovillo at redhat dot com  2004-02-25 19:52 -------
Subject: Re:  [tree-ssa] miscompilation of
	__exchange_and_add (atomicity.h)

On Wed, 2004-02-25 at 13:20, amacleod at redhat dot com wrote:
> ------- Additional Comments From amacleod at redhat dot com  2004-02-25 18:20 -------
> Err, did you try that patch on a testsuite run?
> 
Nope.  I only checked that it fixed this specific problem.  I didn't
mean to apply the patch until you checked it out.

> It seems to me that you still need to look through the operands and kill any
> active partition experssions which are dependent on the uses and defs. Ie, you
> wouldn't make anything replaceable, but you do need to remove things from the
> current search list.
> 
Yes, I had the feeling that it was a bit heavy handed.


Diego.



-- 


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


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

* [Bug optimization/14272] [tree-ssa] miscompilation of __exchange_and_add (atomicity.h)
  2004-02-24 13:35 [Bug c/14272] New: miscompilation of __exchange_and_add (atomicity.h) ehrhardt at mathematik dot uni-ulm dot de
                   ` (10 preceding siblings ...)
  2004-02-25 19:53 ` dnovillo at redhat dot com
@ 2004-02-25 19:54 ` dnovillo at redhat dot com
  2004-02-26 10:19 ` steven at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: dnovillo at redhat dot com @ 2004-02-25 19:54 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From dnovillo at redhat dot com  2004-02-25 19:54 -------
Subject: Re:  [tree-ssa] miscompilation of
	__exchange_and_add (atomicity.h)

On Wed, 2004-02-25 at 13:52, amacleod at redhat dot com wrote:

> However, this appears to fix the problem, I'll do a testrun on it and see if it
> 
> causes any other difficulties.
> 
Sure.  I'd rather go with your approach as it's not as blunt as mine. 
Thanks.


Diego.



-- 


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


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

* [Bug optimization/14272] [tree-ssa] miscompilation of __exchange_and_add (atomicity.h)
  2004-02-24 13:35 [Bug c/14272] New: miscompilation of __exchange_and_add (atomicity.h) ehrhardt at mathematik dot uni-ulm dot de
                   ` (11 preceding siblings ...)
  2004-02-25 19:54 ` dnovillo at redhat dot com
@ 2004-02-26 10:19 ` steven at gcc dot gnu dot org
  2004-02-26 13:07 ` dnovillo at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: steven at gcc dot gnu dot org @ 2004-02-26 10:19 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From steven at gcc dot gnu dot org  2004-02-26 10:19 -------
Gerald, this cures your DLV i386 problems. 
(Perhaps the SPARC ones too??) 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gerald at pfeifer dot com


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


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

* [Bug optimization/14272] [tree-ssa] miscompilation of __exchange_and_add (atomicity.h)
  2004-02-24 13:35 [Bug c/14272] New: miscompilation of __exchange_and_add (atomicity.h) ehrhardt at mathematik dot uni-ulm dot de
                   ` (12 preceding siblings ...)
  2004-02-26 10:19 ` steven at gcc dot gnu dot org
@ 2004-02-26 13:07 ` dnovillo at gcc dot gnu dot org
  2004-02-26 14:56 ` ehrhardt at mathematik dot uni-ulm dot de
                   ` (6 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: dnovillo at gcc dot gnu dot org @ 2004-02-26 13:07 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From dnovillo at gcc dot gnu dot org  2004-02-26 13:06 -------
Fixed by Andrew's patch

http://gcc.gnu.org/ml/gcc-patches/2004-02/msg02473.html

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


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


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

* [Bug optimization/14272] [tree-ssa] miscompilation of __exchange_and_add (atomicity.h)
  2004-02-24 13:35 [Bug c/14272] New: miscompilation of __exchange_and_add (atomicity.h) ehrhardt at mathematik dot uni-ulm dot de
                   ` (13 preceding siblings ...)
  2004-02-26 13:07 ` dnovillo at gcc dot gnu dot org
@ 2004-02-26 14:56 ` ehrhardt at mathematik dot uni-ulm dot de
  2004-02-26 14:59 ` dnovillo at redhat dot com
                   ` (5 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: ehrhardt at mathematik dot uni-ulm dot de @ 2004-02-26 14:56 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From ehrhardt at mathematik dot uni-ulm dot de  2004-02-26 14:56 -------
Subject: Re:  [tree-ssa] miscompilation of __exchange_and_add (atomicity.h)

On Thu, Feb 26, 2004 at 10:19:44AM -0000, steven at gcc dot gnu dot org wrote:
> Gerald, this cures your DLV i386 problems. 
> (Perhaps the SPARC ones too??) 

It fixes this particiular problems but causes other interesting failures
mostly in 64bit mode. But it's probably not the fault of this patch.
I'll look into this a bit more...

    regards  Christian




-- 


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


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

* [Bug optimization/14272] [tree-ssa] miscompilation of __exchange_and_add (atomicity.h)
  2004-02-24 13:35 [Bug c/14272] New: miscompilation of __exchange_and_add (atomicity.h) ehrhardt at mathematik dot uni-ulm dot de
                   ` (15 preceding siblings ...)
  2004-02-26 14:59 ` dnovillo at redhat dot com
@ 2004-02-26 14:59 ` amacleod at redhat dot com
  2004-02-26 15:00 ` ehrhardt at mathematik dot uni-ulm dot de
                   ` (3 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: amacleod at redhat dot com @ 2004-02-26 14:59 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From amacleod at redhat dot com  2004-02-26 14:59 -------
Huh, interesting. 

let me know what you find.
Andrew

-- 


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


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

* [Bug optimization/14272] [tree-ssa] miscompilation of __exchange_and_add (atomicity.h)
  2004-02-24 13:35 [Bug c/14272] New: miscompilation of __exchange_and_add (atomicity.h) ehrhardt at mathematik dot uni-ulm dot de
                   ` (14 preceding siblings ...)
  2004-02-26 14:56 ` ehrhardt at mathematik dot uni-ulm dot de
@ 2004-02-26 14:59 ` dnovillo at redhat dot com
  2004-02-26 14:59 ` amacleod at redhat dot com
                   ` (4 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: dnovillo at redhat dot com @ 2004-02-26 14:59 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From dnovillo at redhat dot com  2004-02-26 14:59 -------
Subject: Re:  [tree-ssa] miscompilation of
	__exchange_and_add (atomicity.h)

On Thu, 2004-02-26 at 09:56, ehrhardt at mathematik dot uni-ulm dot de
wrote:

> It fixes this particiular problems but causes other interesting failures
> mostly in 64bit mode. But it's probably not the fault of this patch.
> I'll look into this a bit more...
> 
>     regards  Christian
> 
Christian,

There were two patches attached to the PR.  The first one (mine) was
incomplete.  Andrew's patch is the one that was committed to the branch
earlier today.

Which patch are you referring to?


Thanks.  Diego.



-- 


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


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

* [Bug optimization/14272] [tree-ssa] miscompilation of __exchange_and_add (atomicity.h)
  2004-02-24 13:35 [Bug c/14272] New: miscompilation of __exchange_and_add (atomicity.h) ehrhardt at mathematik dot uni-ulm dot de
                   ` (16 preceding siblings ...)
  2004-02-26 14:59 ` amacleod at redhat dot com
@ 2004-02-26 15:00 ` ehrhardt at mathematik dot uni-ulm dot de
  2004-02-26 15:02 ` ehrhardt at mathematik dot uni-ulm dot de
                   ` (2 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: ehrhardt at mathematik dot uni-ulm dot de @ 2004-02-26 15:00 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From ehrhardt at mathematik dot uni-ulm dot de  2004-02-26 15:00 -------
Subject: Re:  [tree-ssa] miscompilation of __exchange_and_add (atomicity.h)

On Thu, Feb 26, 2004 at 01:02:00PM -0000, amacleod at redhat dot com wrote:
> I've checked this into the tree-ssa branch

Thanks for the patch! But wouldn't this additional hunk be needed as well?

@@ -2429,7 +2428,7 @@
        }
 
       /* A VDEF kills any expression using a virtual operand.  */
-      if (NUM_VDEFS (VDEF_OPS (ann)) > 0)
+      if ((NUM_VDEFS (VDEF_OPS (ann)) > 0) || ann->has_volatile_ops)
         kill_virtual_exprs (tab, true);
     }
 }

    regards  Christian



-- 


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


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

* [Bug optimization/14272] [tree-ssa] miscompilation of __exchange_and_add (atomicity.h)
  2004-02-24 13:35 [Bug c/14272] New: miscompilation of __exchange_and_add (atomicity.h) ehrhardt at mathematik dot uni-ulm dot de
                   ` (17 preceding siblings ...)
  2004-02-26 15:00 ` ehrhardt at mathematik dot uni-ulm dot de
@ 2004-02-26 15:02 ` ehrhardt at mathematik dot uni-ulm dot de
  2004-02-26 15:15 ` amacleod at redhat dot com
  2004-02-26 15:43 ` ehrhardt at mathematik dot uni-ulm dot de
  20 siblings, 0 replies; 23+ messages in thread
From: ehrhardt at mathematik dot uni-ulm dot de @ 2004-02-26 15:02 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From ehrhardt at mathematik dot uni-ulm dot de  2004-02-26 15:02 -------
Subject: Re:  [tree-ssa] miscompilation of __exchange_and_add (atomicity.h)

On Thu, Feb 26, 2004 at 02:59:35PM -0000, dnovillo at redhat dot com wrote:
> There were two patches attached to the PR.  The first one (mine) was
> incomplete.  Andrew's patch is the one that was committed to the branch
> earlier today.
> 
> Which patch are you referring to?

I know. I'm refering to Andrew's patch!     regards   Christian



-- 


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


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

* [Bug optimization/14272] [tree-ssa] miscompilation of __exchange_and_add (atomicity.h)
  2004-02-24 13:35 [Bug c/14272] New: miscompilation of __exchange_and_add (atomicity.h) ehrhardt at mathematik dot uni-ulm dot de
                   ` (18 preceding siblings ...)
  2004-02-26 15:02 ` ehrhardt at mathematik dot uni-ulm dot de
@ 2004-02-26 15:15 ` amacleod at redhat dot com
  2004-02-26 15:43 ` ehrhardt at mathematik dot uni-ulm dot de
  20 siblings, 0 replies; 23+ messages in thread
From: amacleod at redhat dot com @ 2004-02-26 15:15 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From amacleod at redhat dot com  2004-02-26 15:15 -------
(In reply to comment #20)

> 
> Thanks for the patch! But wouldn't this additional hunk be needed as well?
> 


Indeed, that is probably a good idea since there is an implicit virtual use/def.

Does it resolve your 64 bit problems?


-- 


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


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

* [Bug optimization/14272] [tree-ssa] miscompilation of __exchange_and_add (atomicity.h)
  2004-02-24 13:35 [Bug c/14272] New: miscompilation of __exchange_and_add (atomicity.h) ehrhardt at mathematik dot uni-ulm dot de
                   ` (19 preceding siblings ...)
  2004-02-26 15:15 ` amacleod at redhat dot com
@ 2004-02-26 15:43 ` ehrhardt at mathematik dot uni-ulm dot de
  20 siblings, 0 replies; 23+ messages in thread
From: ehrhardt at mathematik dot uni-ulm dot de @ 2004-02-26 15:43 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From ehrhardt at mathematik dot uni-ulm dot de  2004-02-26 15:43 -------
Subject: Re:  [tree-ssa] miscompilation of __exchange_and_add (atomicity.h)

On Thu, Feb 26, 2004 at 03:15:32PM -0000, amacleod at redhat dot com wrote:
> > Thanks for the patch! But wouldn't this additional hunk be needed as well?
> Indeed, that is probably a good idea since there is an implicit virtual use/def.
> Does it resolve your 64 bit problems?

No it doesn't. But these are most definitely unrelated to the patch.
I've opened PR 14307 for one of these Problems. The reduced testcase
also ICEs other tree-ssa compilers that don't have your patch. Your
patch does seem to trigger this other bug more often during bootstrap
though. Given that these problems should not be a showstopper for the patch.

    regards   Christian



-- 


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


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

end of thread, other threads:[~2004-02-26 15:43 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-24 13:35 [Bug c/14272] New: miscompilation of __exchange_and_add (atomicity.h) ehrhardt at mathematik dot uni-ulm dot de
2004-02-24 14:26 ` [Bug optimization/14272] [tree-ssa] " pinskia at gcc dot gnu dot org
2004-02-24 14:48 ` ehrhardt at mathematik dot uni-ulm dot de
2004-02-25 12:40 ` steven at gcc dot gnu dot org
2004-02-25 13:32 ` steven at gcc dot gnu dot org
2004-02-25 13:43 ` steven at gcc dot gnu dot org
2004-02-25 14:02   ` Christian Ehrhardt
2004-02-25 14:02 ` ehrhardt at mathematik dot uni-ulm dot de
2004-02-25 14:06 ` amacleod at redhat dot com
2004-02-25 14:08 ` dnovillo at redhat dot com
2004-02-25 18:06 ` dnovillo at redhat dot com
2004-02-25 18:20 ` amacleod at redhat dot com
2004-02-25 19:53 ` dnovillo at redhat dot com
2004-02-25 19:54 ` dnovillo at redhat dot com
2004-02-26 10:19 ` steven at gcc dot gnu dot org
2004-02-26 13:07 ` dnovillo at gcc dot gnu dot org
2004-02-26 14:56 ` ehrhardt at mathematik dot uni-ulm dot de
2004-02-26 14:59 ` dnovillo at redhat dot com
2004-02-26 14:59 ` amacleod at redhat dot com
2004-02-26 15:00 ` ehrhardt at mathematik dot uni-ulm dot de
2004-02-26 15:02 ` ehrhardt at mathematik dot uni-ulm dot de
2004-02-26 15:15 ` amacleod at redhat dot com
2004-02-26 15:43 ` ehrhardt at mathematik dot uni-ulm dot de

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