From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42062) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPZq3-0004dN-TL for qemu-devel@nongnu.org; Tue, 19 Jul 2016 14:33:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPZpz-0002Ip-Pt for qemu-devel@nongnu.org; Tue, 19 Jul 2016 14:33:50 -0400 Received: from mail-yw0-x232.google.com ([2607:f8b0:4002:c05::232]:35592) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPZpz-0002I8-LC for qemu-devel@nongnu.org; Tue, 19 Jul 2016 14:33:47 -0400 Received: by mail-yw0-x232.google.com with SMTP id j12so17050697ywb.2 for ; Tue, 19 Jul 2016 11:33:47 -0700 (PDT) References: <20160714202940.18399-1-bobby.prani@gmail.com> <87bn1tmxk4.fsf@linaro.org> From: Pranith Kumar In-reply-to: <87bn1tmxk4.fsf@linaro.org> Date: Tue, 19 Jul 2016 14:33:44 -0400 Message-ID: <871t2pfpfb.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [RFC PATCH] tcg: Optimize fence instructions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex =?utf-8?Q?Benn=C3=A9e?= Cc: Richard Henderson , "open list:All patches CC here" , serge.fdrv@gmail.com Alex Bennée writes: > Pranith Kumar writes: > >> This patch applies on top of the fence generation patch series. >> >> This commit optimizes fence instructions. Two optimizations are >> currently implemented. These are: >> >> 1. Unnecessary duplicate fence instructions >> >> If the same fence instruction is detected consecutively, we remove >> one instance of it. >> >> ex: mb; mb => mb, strl; strl => strl >> >> 2. Merging weaker fence with subsequent/previous stronger fence >> >> load-acquire/store-release fence can be combined with a full fence >> without relaxing the ordering constraint. >> >> ex: a) ld; ldaq; mb => ld; mb >> b) mb; strl; st => mb; st > > What test cases do you have for this? > > Currently the litmus tests don't fire (as they have exactly what they > need). Most programs don't seem to trigger multiple barriers. > Indeed, these cases are not so commonly seen in the wild. To test it I wrote small test programs using C11 builtins to generate appropriate instructions. Then verified it by running 'qemu-aarch64 -d in_asm,out_asm'. _Atomic int val; int main() { val = __atomic_load_n(&val, __ATOMIC_ACQUIRE); __atomic_store_n(&val, val, __ATOMIC_RELEASE); barrier(); barrier(); } -- Pranith