This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: patch for volatile/immediate comparison
- To: Christian Bruel <christian dot bruel at st dot com>
- Subject: Re: patch for volatile/immediate comparison
- From: Jeffrey A Law <law at upchuck dot cygnus dot com>
- Date: Sat, 03 Apr 1999 15:57:03 -0700
- cc: egcs-patches at egcs dot cygnus dot com
- Reply-To: law at cygnus dot com
In message <199903221602.RAA27097@eux100.sgp.st.com>you write:
> As you can see, the immediate 'i' is moved to a register to perform the
> comparison. The reason seems to be that the "general_operand" predicate
> refuses MEM operands when the "volatile_ok" flag is not set.
>
> However, I think the semantic on volatile variables could be preserved with
> memory compares, because the number of load/stores on the address is kept.
I don't think this is safe. You have no guarantee that the target will only
read the value once.
Consider a target in which it requires 2 component instructions to generate a
proper set of condition code bits for a comparison. We could end up reading
from memory twice, which is bad.
The only reasonable way I can see to do this without breaking the semantics of
volatile is for the *backend* to indicate explicitly what operations will
adhere to volatile semantics by using a different predicate for operands which
can be volatile memory.
jeff