patch for volatile/immediate comparison
Jeffrey A Law
law@upchuck.cygnus.com
Sat Apr 3 15:08:00 GMT 1999
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
More information about the Gcc-patches
mailing list