Hi! Here's a patch for PR47698, which is about CMOV should not be generated for memory address marked as volatile. Successfully bootstrapped and passed make check on x86_64-unknown-linux-gnu.
Is it Ok?
regards,
Sergos
/gcc
2011-10-27 Sergey Ostanevich
PR rtl-optimization/47698
* config/i386/i386.c (ix86_expand_int_movcc) prevent CMOV generation
for volatile mem
/testsuite
2011-10-27 Sergey Ostanevich
PR rtl-optimization/47698
* gcc.target/i386/47698.c: New test
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;
+}
47698.patch
Description: Binary data
