From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41343) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPZmN-0000Ai-I4 for qemu-devel@nongnu.org; Tue, 19 Jul 2016 14:30:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPZmK-00014a-EH for qemu-devel@nongnu.org; Tue, 19 Jul 2016 14:30:03 -0400 Received: from mail-yw0-x244.google.com ([2607:f8b0:4002:c05::244]:33106) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPZmK-00014Q-9N for qemu-devel@nongnu.org; Tue, 19 Jul 2016 14:30:00 -0400 Received: by mail-yw0-x244.google.com with SMTP id z8so168210ywa.0 for ; Tue, 19 Jul 2016 11:30:00 -0700 (PDT) References: <20160714202940.18399-1-bobby.prani@gmail.com> <87d1m9n19j.fsf@linaro.org> From: Pranith Kumar In-reply-to: <87d1m9n19j.fsf@linaro.org> Date: Tue, 19 Jul 2016 14:29:56 -0400 Message-ID: <8737n5fpln.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 >> >> Signed-off-by: Pranith Kumar >> --- >> tcg/optimize.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ >> tcg/tcg.h | 1 + >> 2 files changed, 60 insertions(+) >> >> diff --git a/tcg/optimize.c b/tcg/optimize.c >> index c0d975b..a655829 100644 >> --- a/tcg/optimize.c >> +++ b/tcg/optimize.c >> @@ -569,6 +569,63 @@ static bool swap_commutative2(TCGArg *p1, TCGArg *p2) >> return false; >> } >> >> +/* Eliminate duplicate and unnecessary fence instructions */ >> +void tcg_optimize_mb(TCGContext *s) >> +{ >> + int oi, oi_next; >> + TCGArg prev_op_mb = -1; >> + TCGOp *prev_op; > > > The compiler throws up warnings about prev_op not being set: > > /home/alex/lsrc/qemu/qemu.git/tcg/optimize.c: In function ‘tcg_optimize_mb’: > /home/alex/lsrc/qemu/qemu.git/tcg/optimize.c:611:17: error: ‘prev_op’ may be used uninitialized in this function [-Werror=maybe-uninitialized] > tcg_op_remove(s, prev_op); > ^ OK, I will fix this. Thanks, -- Pranith