From patchwork Tue Aug 29 20:47:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 9928281 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5DE1960380 for ; Tue, 29 Aug 2017 20:52:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EF4628A5C for ; Tue, 29 Aug 2017 20:52:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 430E528A5F; Tue, 29 Aug 2017 20:52:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9559528A5C for ; Tue, 29 Aug 2017 20:52:01 +0000 (UTC) Received: from localhost ([::1]:46903 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmnUO-0004e9-QP for patchwork-qemu-devel@patchwork.kernel.org; Tue, 29 Aug 2017 16:52:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49546) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmnQn-0002Xf-UW for qemu-devel@nongnu.org; Tue, 29 Aug 2017 16:48:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmnQm-0001Wc-Bx for qemu-devel@nongnu.org; Tue, 29 Aug 2017 16:48:18 -0400 Received: from mail-pf0-x22b.google.com ([2607:f8b0:400e:c00::22b]:33713) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dmnQm-0001WS-3R for qemu-devel@nongnu.org; Tue, 29 Aug 2017 16:48:16 -0400 Received: by mail-pf0-x22b.google.com with SMTP id r62so13445484pfj.0 for ; Tue, 29 Aug 2017 13:48:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7EKO1ayOrpPVDOid0Oz0SpWK65aO/ZVIVhQGxN0Ans4=; b=QS2vjLqTSDVAWQ/zvYxiWo6s6J1Y3MudsfEvSlTIln7j/lmrkOMtJWqUiUmqCdpASJ KkyHyLz7nnwzBdRnzI0oUMbdnBPqRHJ+sC7ANQp0AATfrm4fUrGDyYK5VhX9jGAQIfHO OJny5XMRbE4aYlUE24N0U0k1FS8IO5sqVbQ94= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7EKO1ayOrpPVDOid0Oz0SpWK65aO/ZVIVhQGxN0Ans4=; b=drSqcRoJ9ighCYiiaPNvg4nohJ2MJkQ82+ssIBUug1/dwXFxi+qA9VkKJ3pcieLxEI rECDzWR+T65z5F4OF8hIsUPaRo2sNtxcZugIhNNoScd1gm/06oumYKtCbnun5TK53vNJ v7dX4vY+B7ffuDfE199nD1XNhrDz9lshfU16aQ3hthBu1z068/ACBAiPb+ABBRfcKRjW kKyke/qVUnxAIdg0GFwm6H92o5k4cYhq3XeCamyYcY2ZX4kAmY7DzhUIXNokJImuM+OH aq4WsoCdr6M+v8XmS2Ksb2is22Zwursb5T/1tqoBasvUSzyzKo4O1Tw4Mm9ofw+HM7w+ HAuQ== X-Gm-Message-State: AHYfb5jY7Yx+uSdo3HIbtIqdu4kSHceR0GJ3YWRKGjB6SXiJOwesb3gQ rslXz3+NC0L8XZvfytbW8g== X-Received: by 10.84.175.195 with SMTP id t61mr1970034plb.240.1504039694769; Tue, 29 Aug 2017 13:48:14 -0700 (PDT) Received: from bigtime.twiddle.net (97-126-108-236.tukw.qwest.net. [97.126.108.236]) by smtp.gmail.com with ESMTPSA id i84sm6633646pfj.139.2017.08.29.13.48.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Aug 2017 13:48:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 29 Aug 2017 13:47:59 -0700 Message-Id: <20170829204759.6853-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170829204759.6853-1-richard.henderson@linaro.org> References: <20170829204759.6853-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::22b Subject: [Qemu-devel] [PATCH 8/8] tcg/s390: Use slbgr for setcond le and leu X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: borntraeger@de.ibm.com, cohuck@redhat.com, agraf@suse.de, Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Richard Henderson Signed-off-by: Richard Henderson --- tcg/s390/tcg-target.inc.c | 119 +++++++++++++++++----------------------------- 1 file changed, 43 insertions(+), 76 deletions(-) diff --git a/tcg/s390/tcg-target.inc.c b/tcg/s390/tcg-target.inc.c index 0de968fde2..38b9e791ee 100644 --- a/tcg/s390/tcg-target.inc.c +++ b/tcg/s390/tcg-target.inc.c @@ -1084,11 +1084,20 @@ static void tgen_setcond(TCGContext *s, TCGType type, TCGCond cond, have_loc = (s390_facilities & FACILITY_LOAD_ON_COND) != 0; - /* For HAVE_LOC, only the path through do_greater is smaller. */ + /* For HAVE_LOC, only the paths through GTU/GT/LEU/LE are smaller. */ + restart: switch (cond) { + case TCG_COND_NE: + /* X != 0 is X > 0. */ + if (c2const && c2 == 0) { + cond = TCG_COND_GTU; + } else { + break; + } + /* fallthru */ + case TCG_COND_GTU: case TCG_COND_GT: - do_greater: /* The result of a compare has CC=2 for GT and CC=3 unused. ADD LOGICAL WITH CARRY considers (CC & 2) the carry bit. */ tgen_cmp(s, type, cond, c1, c2, c2const, true); @@ -1096,49 +1105,33 @@ static void tgen_setcond(TCGContext *s, TCGType type, TCGCond cond, tcg_out_insn(s, RRE, ALCGR, dest, dest); return; - case TCG_COND_GEU: - if (have_loc) { - goto do_loc; - } - do_geu: - /* We need "real" carry semantics, so use SUBTRACT LOGICAL - instead of COMPARE LOGICAL. This may need an extra move. */ - if (c2const) { - tcg_out_mov(s, type, TCG_TMP0, c1); - if (type == TCG_TYPE_I32) { - tcg_out_insn(s, RIL, SLFI, TCG_TMP0, c2); - } else { - tcg_out_insn(s, RIL, SLGFI, TCG_TMP0, c2); - } - } else if (s390_facilities & FACILITY_DISTINCT_OPS) { - if (type == TCG_TYPE_I32) { - tcg_out_insn(s, RRF, SLRK, TCG_TMP0, c1, c2); - } else { - tcg_out_insn(s, RRF, SLGRK, TCG_TMP0, c1, c2); - } + case TCG_COND_EQ: + /* X == 0 is X <= 0. */ + if (c2const && c2 == 0) { + cond = TCG_COND_LEU; } else { - tcg_out_mov(s, type, TCG_TMP0, c1); - if (type == TCG_TYPE_I32) { - tcg_out_insn(s, RR, SLR, TCG_TMP0, c2); - } else { - tcg_out_insn(s, RRE, SLGR, TCG_TMP0, c2); - } + break; } - tcg_out_movi(s, TCG_TYPE_I64, dest, 0); - tcg_out_insn(s, RRE, ALCGR, dest, dest); - return; + /* fallthru */ case TCG_COND_LEU: - if (have_loc) { - goto do_loc; - } - /* fallthru */ + case TCG_COND_LE: + /* As above, but we're looking for borrow, or !carry. + The second insn computes d - d - borrow, or -1 for true + and 0 for false. So we must mask to 1 bit afterward. */ + tgen_cmp(s, type, cond, c1, c2, c2const, true); + tcg_out_insn(s, RRE, SLBGR, dest, dest); + tgen_andi(s, type, dest, 1); + return; + + case TCG_COND_GEU: case TCG_COND_LTU: case TCG_COND_LT: - /* Swap operands so that we can use GEU/GTU/GT. */ + case TCG_COND_GE: + /* Swap operands so that we can use LEU/GTU/GT/LE. */ if (c2const) { if (have_loc) { - goto do_loc; + break; } tcg_out_movi(s, type, TCG_TMP0, c2); c2 = c1; @@ -1149,51 +1142,25 @@ static void tgen_setcond(TCGContext *s, TCGType type, TCGCond cond, c1 = c2; c2 = t; } - if (cond == TCG_COND_LEU) { - goto do_geu; - } cond = tcg_swap_cond(cond); - goto do_greater; - - case TCG_COND_NE: - /* X != 0 is X > 0. */ - if (c2const && c2 == 0) { - cond = TCG_COND_GTU; - goto do_greater; - } - break; - - case TCG_COND_EQ: - if (have_loc) { - goto do_loc; - } - /* X == 0 is X <= 0 is 0 >= X. */ - if (c2const && c2 == 0) { - tcg_out_movi(s, TCG_TYPE_I64, TCG_TMP0, 0); - c2 = c1; - c2const = 0; - c1 = TCG_TMP0; - goto do_geu; - } - break; + goto restart; default: - break; + g_assert_not_reached(); } cc = tgen_cmp(s, type, cond, c1, c2, c2const, false); - /* Emit: d = 1; if (cc) goto over; d = 0; over: */ - tcg_out_movi(s, type, dest, 1); - tcg_out_insn(s, RI, BRC, cc, (4 + 4) >> 1); - tcg_out_movi(s, type, dest, 0); - return; - - do_loc: - cc = tgen_cmp(s, type, cond, c1, c2, c2const, false); - /* Emit: d = 0, t = 1, d = (cc ? t : d). */ - tcg_out_movi(s, TCG_TYPE_I64, dest, 0); - tcg_out_movi(s, TCG_TYPE_I64, TCG_TMP0, 1); - tcg_out_insn(s, RRF, LOCGR, dest, TCG_TMP0, cc); + if (have_loc) { + /* Emit: d = 0, t = 1, d = (cc ? t : d). */ + tcg_out_movi(s, TCG_TYPE_I64, dest, 0); + tcg_out_movi(s, TCG_TYPE_I64, TCG_TMP0, 1); + tcg_out_insn(s, RRF, LOCGR, dest, TCG_TMP0, cc); + } else { + /* Emit: d = 1; if (cc) goto over; d = 0; over: */ + tcg_out_movi(s, type, dest, 1); + tcg_out_insn(s, RI, BRC, cc, (4 + 4) >> 1); + tcg_out_movi(s, type, dest, 0); + } } static void tgen_movcond(TCGContext *s, TCGType type, TCGCond c, TCGReg dest,