public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [PATCH i386] PR47698 no CMOV for volatile mem
@ 2011-10-27 19:47 Uros Bizjak
  2011-10-28  8:49 ` Richard Guenther
  0 siblings, 1 reply; 12+ messages in thread
From: Uros Bizjak @ 2011-10-27 19:47 UTC (permalink / raw)
  To: gcc-patches; +Cc: Sergey Ostanevich, H.J. Lu, Richard Guenther

Hello!

> 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.


	PR rtl-optimization/47698
	* config/i386/i386.c (ix86_expand_int_movcc) prevent CMOV generation
	for volatile mem

	PR rtl-optimization/47698
	* gcc.target/i386/47698.c: New test

Please use punctuation marks and correct capitalization in ChangeLog entries.

OTOH, do we want to fix this per-target, or in the middle-end?

Uros.

^ permalink raw reply	[flat|nested] 12+ messages in thread
* [PATCH i386] PR47698 no CMOV for volatile mem
@ 2011-10-27 13:04 Sergey Ostanevich
  2011-10-28  1:44 ` Richard Henderson
  0 siblings, 1 reply; 12+ messages in thread
From: Sergey Ostanevich @ 2011-10-27 13:04 UTC (permalink / raw)
  To: gcc-patches; +Cc: H.J. Lu

[-- Attachment #1: Type: text/plain, Size: 1528 bytes --]

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;
+}

[-- Attachment #2: 47698.patch --]
[-- Type: application/octet-stream, Size: 1080 bytes --]

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;
+}


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2011-11-07 20:57 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-27 19:47 [PATCH i386] PR47698 no CMOV for volatile mem Uros Bizjak
2011-10-28  8:49 ` Richard Guenther
2011-10-28 13:25   ` Sergey Ostanevich
2011-10-28 13:39     ` Richard Guenther
2011-10-28 15:49       ` Sergey Ostanevich
2011-10-28 21:55         ` Sergey Ostanevich
2011-11-02 11:55           ` Richard Guenther
2011-11-06 18:48             ` Sergey Ostanevich
2011-11-07 21:00               ` Eric Botcazou
2011-10-28 16:07     ` Richard Henderson
  -- strict thread matches above, loose matches on Subject: below --
2011-10-27 13:04 Sergey Ostanevich
2011-10-28  1:44 ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).