From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3404 invoked by alias); 19 Aug 2015 19:07:36 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 3369 invoked by uid 48); 19 Aug 2015 19:07:30 -0000 From: "tuliom at linux dot vnet.ibm.com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/67281] HTM builtins aren't treated as compiler barriers on powerpc Date: Wed, 19 Aug 2015 19:07:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: tuliom at linux dot vnet.ibm.com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-08/txt/msg01365.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67281 --- Comment #4 from Tulio Magno Quites Machado Filho --- (In reply to Andrew Pinski from comment #3) > Since there are no stores, the load seems like it can be pulled out of the > loop too. I disagree with you. If I use the value of dest to take a decision inside the transaction, I need the memory barrier before the access to *src0. Here's an example: long foo (long dest, long *src0, long src1, long tries) { long i; for (i = 0; i < tries; i++) { __builtin_tbegin (0); dest = *src0 + src1; if (dest == 13) __builtin_tabort(0); __builtin_tend (0); } return dest; } In other words, if you access *src0 before the memory barrier, its value may change when the memory barrier is created. This is particularly useful if dest says if a lock has been acquired by another thread or not. For the reference, this has been found in glibc source code: https://sourceware.org/ml/libc-alpha/2015-07/msg00986.html