public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* CRIS atomics revisited 2/4: don't allow a memory operand (with possible side-effects)
@ 2012-07-16  3:43 Hans-Peter Nilsson
  0 siblings, 0 replies; only message in thread
From: Hans-Peter Nilsson @ 2012-07-16  3:43 UTC (permalink / raw)
  To: gcc-patches

Buglet in "atomic_compare_and_swap<mode>", allowing (in theory)
a volatile or post-increment memory operand.  Simplest and
safest fixed by excluding all memory operands.

gcc:
	* config/cris/sync.md ("atomic_compare_and_swap<mode>"): Change
	predicate to nonmemory_operand for operand 3.  Add FIXME.
	("cris_atomic_compare_and_swap<mode>_1"): Change predicates and
	constraints for operand 3 to exclude memory.

Index: config/cris/sync.md
===================================================================
--- config/cris/sync.md	(revision 189500)
+++ config/cris/sync.md	(working copy)
@@ -184,11 +184,12 @@ (define_insn "cris_atomic_fetch_<atomic_
 ;; can_compare_and_swap_p call in omp-low.c, 4.8 era).  We'd slightly
 ;; prefer atomic_exchange<mode> over this, but having both would be
 ;; redundant.
+;; FIXME: handle memory without side-effects for operand[3].
 (define_expand "atomic_compare_and_swap<mode>"
   [(match_operand:SI 0 "register_operand")
    (match_operand:BWD 1 "register_operand")
    (match_operand:BWD 2 "memory_operand")
-   (match_operand:BWD 3 "general_operand")
+   (match_operand:BWD 3 "nonmemory_operand")
    (match_operand:BWD 4 "register_operand")
    (match_operand 5)
    (match_operand 6)
@@ -218,7 +219,7 @@ (define_insn "cris_atomic_compare_and_sw
   [(set (match_operand:SI 0 "register_operand" "=&r")
 	(unspec_volatile:SI
 	 [(match_operand:BWD 2 "memory_operand" "+Q")
-	  (match_operand:BWD 3 "general_operand" "g")]
+	  (match_operand:BWD 3 "nonmemory_operand" "ri")]
 	 CRIS_UNSPEC_ATOMIC_SWAP_BOOL))
    (set (match_operand:BWD 1 "register_operand" "=&r") (match_dup 2))
    (set (match_dup 2)

brgds, H-P

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

only message in thread, other threads:[~2012-07-16  3:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-16  3:43 CRIS atomics revisited 2/4: don't allow a memory operand (with possible side-effects) Hans-Peter Nilsson

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