public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dnovillo at redhat dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug optimization/14272] [tree-ssa] miscompilation of __exchange_and_add (atomicity.h)
Date: Wed, 25 Feb 2004 18:06:00 -0000	[thread overview]
Message-ID: <20040225180635.17891.qmail@sources.redhat.com> (raw)
In-Reply-To: <20040224133459.14272.ehrhardt@mathematik.uni-ulm.de>


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


  parent reply	other threads:[~2004-02-25 18:06 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-24 13:35 [Bug c/14272] New: " 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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040225180635.17891.qmail@sources.redhat.com \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).