Patchwork Fix alias set of memories created for atomic ops

login
register
mail settings
Submitter Richard Henderson
Date Nov. 17, 2011, 12:28 a.m.
Message ID <4EC4552B.40107@redhat.com>
Download mbox | patch
Permalink /patch/126093/
State New
Headers show

Comments

Richard Henderson - Nov. 17, 2011, 12:28 a.m.
Both Alpha and PPC create aligned memories for sub-word
atomic ops.  Neither were updated when ALIAS_SET_MEMORY_BARRIER
was invented.

I've no test case that fails because of this, just found
by inspection.

Built cross-compilers to both targets.  Committed.


r~
* config/alpha/alpha.c (alpha_split_compare_and_swap_12): Copy
	ALIAS_SET_MEMORY_BARRIER when creating a new memory.
	(alpha_split_atomic_exchange_12): Likewise.
	* config/rs6000/rs6000.c (rs6000_adjust_atomic_subword): Likewise.

Patch

diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c
index 78717f9..e970227 100644
--- a/gcc/config/alpha/alpha.c
+++ b/gcc/config/alpha/alpha.c
@@ -4444,6 +4444,8 @@  alpha_split_compare_and_swap_12 (rtx operands[])
 
   mem = gen_rtx_MEM (DImode, align);
   MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (orig_mem);
+  if (MEM_ALIAS_SET (orig_mem) == ALIAS_SET_MEMORY_BARRIER)
+    set_mem_alias_set (mem, ALIAS_SET_MEMORY_BARRIER);
 
   alpha_pre_atomic_barrier (mod_s);
 
@@ -4583,6 +4585,8 @@  alpha_split_atomic_exchange_12 (rtx operands[])
 
   mem = gen_rtx_MEM (DImode, align);
   MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (orig_mem);
+  if (MEM_ALIAS_SET (orig_mem) == ALIAS_SET_MEMORY_BARRIER)
+    set_mem_alias_set (mem, ALIAS_SET_MEMORY_BARRIER);
 
   alpha_pre_atomic_barrier (model);
 
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 4436ed0..199c639 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -17244,16 +17244,16 @@  rs6000_post_atomic_barrier (enum memmodel model)
    which to shift and mask.  */
 
 static rtx
-rs6000_adjust_atomic_subword (rtx mem, rtx *pshift, rtx *pmask)
+rs6000_adjust_atomic_subword (rtx orig_mem, rtx *pshift, rtx *pmask)
 {
-  rtx addr, align, shift, mask;
+  rtx addr, align, shift, mask, mem;
   HOST_WIDE_INT shift_mask;
-  enum machine_mode mode = GET_MODE (mem);
+  enum machine_mode mode = GET_MODE (orig_mem);
 
   /* For smaller modes, we have to implement this via SImode.  */
   shift_mask = (mode == QImode ? 0x18 : 0x10);
 
-  addr = XEXP (mem, 0);
+  addr = XEXP (orig_mem, 0);
   addr = force_reg (GET_MODE (addr), addr);
 
   /* Aligned memory containing subword.  Generate a new memory.  We
@@ -17262,7 +17262,9 @@  rs6000_adjust_atomic_subword (rtx mem, rtx *pshift, rtx *pmask)
   align = expand_simple_binop (Pmode, AND, addr, GEN_INT (-4),
 			       NULL_RTX, 1, OPTAB_LIB_WIDEN);
   mem = gen_rtx_MEM (SImode, align);
-  MEM_VOLATILE_P (mem) = 1;
+  MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (orig_mem);
+  if (MEM_ALIAS_SET (orig_mem) == ALIAS_SET_MEMORY_BARRIER)
+    set_mem_alias_set (mem, ALIAS_SET_MEMORY_BARRIER);
 
   /* Shift amount for subword relative to aligned word.  */
   shift = gen_reg_rtx (SImode);