public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [SPARC] Add peephole for memory barriers
@ 2013-09-29 20:55 Eric Botcazou
  0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2013-09-29 20:55 UTC (permalink / raw)
  To: gcc-patches

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

This is a bit gross, but this prevents consecutive memory barriers from being 
generated, for example on accesses to atomic objects in Ada.

Tested on SPARC/Solaris, applied on the mainline.


2013-09-29  Eric Botcazou  <ebotcazou@adacore.com>

	* config/sparc/sync.md: Add peephole for consecutive memory barriers.


-- 
Eric Botcazou

[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 861 bytes --]

Index: config/sparc/sync.md
===================================================================
--- config/sparc/sync.md	(revision 202912)
+++ config/sparc/sync.md	(working copy)
@@ -93,6 +93,18 @@ (define_insn "*membar"
   "membar\t%1"
   [(set_attr "type" "multi")])
 
+(define_peephole2
+  [(set (match_operand:BLK 0 "" "")
+	(unspec:BLK [(match_dup 0) (match_operand:SI 1 "const_int_operand")]
+		    UNSPEC_MEMBAR))
+   (set (match_operand:BLK 2 "" "")
+	(unspec:BLK [(match_dup 2) (match_operand:SI 3 "const_int_operand")]
+		    UNSPEC_MEMBAR))]
+  ""
+  [(set (match_operand:BLK 0 "" "")
+	(unspec:BLK [(match_dup 0) (match_dup 1)] UNSPEC_MEMBAR))]
+{ operands[1] = GEN_INT (UINTVAL (operands[1]) | UINTVAL (operands[3])); })
+
 (define_expand "atomic_load<mode>"
   [(match_operand:I 0 "register_operand" "")
    (match_operand:I 1 "memory_operand" "")

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-09-29 17:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-29 20:55 [SPARC] Add peephole for memory barriers Eric Botcazou

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