Message ID | CAGYS_TK=XcXTzyM6bv8Xn2L8KW7n2iUiRiE9TJ+Q0MAbj8N0Hg@mail.gmail.com |
---|---|
State | New |
Headers | show |
On 10/27/2011 05:17 AM, Sergey Ostanevich wrote: > + /* MOVCC semantics implies that source is always read which is wrong > + for devices I/O that are defined using volatile in C. PR47698 */ > + > + if (MEM_P (operands[2]) && MEM_VOLATILE_P (operands[2])) > + return false; This looks to be at the wrong level. This fix should be tested in ifcvt.c where we attempted this. r~
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index c6e09ae..afe5de3 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -18312,6 +18312,12 @@ ix86_expand_int_movcc (rtx operands[]) rtx op0 = XEXP (operands[1], 0); rtx op1 = XEXP (operands[1], 1); + /* MOVCC semantics implies that source is always read which is wrong + for devices I/O that are defined using volatile in C. PR47698 */ + + if (MEM_P (operands[2]) && MEM_VOLATILE_P (operands[2])) + return false; + start_sequence (); compare_op = ix86_expand_compare (code, op0, op1); compare_seq = get_insns (); diff --git a/gcc/testsuite/gcc.target/i386/47698.c b/gcc/testsuite/gcc.target/i386/47698.c new file mode 100644 index 0000000..2c75109 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/47698.c @@ -0,0 +1,10 @@ +/* { dg-options "-Os" } */ +/* { dg-final { scan-assembler-not "cmov" } } */ + +extern volatile unsigned long mmio; +unsigned long foo(int cond) +{ + if (cond) + return mmio; + return 0; +}