This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: patch for volatile/immediate comparison



  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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]