From patchwork Thu Nov 17 11:07:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: powerpc lack of memory_barrier Date: Thu, 17 Nov 2011 01:07:13 -0000 From: Alan Modra X-Patchwork-Id: 126184 Message-Id: <20111117110713.GZ14325@bubble.grove.modra.org> To: gcc-patches@gcc.gnu.org Cc: David Edelsohn Lacking this pattern means the builtin __sync_synchronize() on powerpc is just an asm with a memory clobber (see builtins.c), which is hardly a "full memory barrier" as extend.texi says it should be. This patch fixes multiple libgomp testsuite failures. Bootstrapped and regression tested powerpc-linux. OK for mainline? * config/rs6000/sync.md: Duplicate hwsync as memory_barrier. Index: gcc/config/rs6000/sync.md =================================================================== --- gcc/config/rs6000/sync.md (revision 181425) +++ gcc/config/rs6000/sync.md (working copy) @@ -53,6 +53,15 @@ (define_expand "mem_thread_fence" DONE; }) +(define_expand "memory_barrier" + [(set (match_dup 0) + (unspec:BLK [(match_dup 0)] UNSPEC_SYNC))] + "" +{ + operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode)); + MEM_VOLATILE_P (operands[0]) = 1; +}) + (define_expand "hwsync" [(set (match_dup 0) (unspec:BLK [(match_dup 0)] UNSPEC_SYNC))]