From patchwork Wed Sep 6 14:49:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 111791 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1001594qge; Wed, 6 Sep 2017 07:56:58 -0700 (PDT) X-Received: by 10.55.60.131 with SMTP id j125mr4136363qka.335.1504709817914; Wed, 06 Sep 2017 07:56:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504709817; cv=none; d=google.com; s=arc-20160816; b=nLrozMj9ZS/OL1hlvQllfcl8Ir7es+9v/fA7vtkBf9H+3XQ6YiDoDbXGkI54LhCU+O t/DeC13Mjamf94nB64cnbr5LxfOrY8gCsWlayFh9rp04wN7LZEDlpr7p8vxo3e+5osS+ +b5NzlkwgBPkXrqeRb+eRldZZdXDSlUhXwS2qd0rmoCc8nVtev5JY5vkJVZ1TXBZw27m TX0OMPlGx5RV6sitdA7/lRVkIySsnhE40UMKMNObotSVEJlU0QlsDGHyvXgoTN1t6a/n dm7LcwLniWRYwN778jq1I1xOuqFO69j1rbmzgTzMV5FzmAG9tAMBwKAMewfR8bcS8/W/ P5jQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=pyrCD0X5hMABEfynCC0ORcitRg8eEvaZTchNZ88dfPM=; b=TsL6FGp1PH9BAed8pgARt9WYy2Fp2ZClGngs+D4RJWpYdOondkHR4d8+abDuGIXwhp JnKTVwqIy8Mr1kKmVaqwhQVGVmB23/OSPZ42O/rtaRpEFm1OJNa4rxVL74/YASUeEOIW 8dq/kOaFfQkVXZAUtRD+MMNp6egS0qgbgfxNuxGvme4BLWh2QPDi4BBbuuUi1D5wozEA QxjR59pSl89Nq9FXdZTpGHfOEEWtC2kZYpdQ6s0SszZtFZNYsakeQDcA8zdA4jAZO2It Nq/JKgpTvtr1Lcizp/UIFc5uiUu95u5wg4wPFXGWGyVylEtHUbtn1s96COrFY+Fs2IVP 2ZKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=j93xauiE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id p66si43782qka.85.2017.09.06.07.56.57 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 06 Sep 2017 07:56:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=j93xauiE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:36552 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpbl9-0002Zs-GI for patch@linaro.org; Wed, 06 Sep 2017 10:56:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40121) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpbea-0005en-Ko for qemu-devel@nongnu.org; Wed, 06 Sep 2017 10:50:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpbeU-0000SR-FX for qemu-devel@nongnu.org; Wed, 06 Sep 2017 10:50:08 -0400 Received: from mail-pf0-x22d.google.com ([2607:f8b0:400e:c00::22d]:36792) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dpbeU-0000S4-7s for qemu-devel@nongnu.org; Wed, 06 Sep 2017 10:50:02 -0400 Received: by mail-pf0-x22d.google.com with SMTP id e199so13133570pfh.3 for ; Wed, 06 Sep 2017 07:50:02 -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=pyrCD0X5hMABEfynCC0ORcitRg8eEvaZTchNZ88dfPM=; b=j93xauiEQK4tZCAQAtxwQ5Mw2EiZym6rkBPJ8FM8C4J/MAo/tZNR4nva6wXLe7VTZ6 bpGXSruwrjlbF+KxJUHFw8D/yYQtvPse+g6a0Dh27+L1WEiBHBQctkUZn2yVM4RbggBn V8CzaQlTGEaioCghJuBlFPwcFHDJwtH7rQ8XE= 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=pyrCD0X5hMABEfynCC0ORcitRg8eEvaZTchNZ88dfPM=; b=pnCVXmiTCFGNGH95tWqMXRy6M8GtJrc3wfNJAeT/bedP2u23KZgIn/+XS0I5AU/H0A W/UXOB9DvciHykZIGZpe6jm7RV7jgW0z55oEcqkM1LwZqpewB9f9LB39ijx9myZs4fV+ JPpkcdC0pw4c9TdCP8Um88lDAyBhn4PoDtmmcXOuHrh8yi1k+cTO2MNZrlDUceUgcqVS otASqkHyuZkO105rZN2jawM6dLd67J7whOCEkVnzvW7j3dSIs6TERd1THy+Xj7gR901c fuA3HA3U0LXkn1M5/kLxrzuiITvhhQ6lVMQVZm+7Om5ye7wDfxeOpZFjSM7guDN+0pcO pLSQ== X-Gm-Message-State: AHPjjUi1ogVncwJK7XXJAnQ3n5cdEyoDhJKQDTpN8PGQitbTozlZeEiO 2Zp3kfsqrR5d2mD9gOWqjw== X-Google-Smtp-Source: ADKCNb5UdTCm89z0TWiIlymUurd0AH9MBww2STj/tDo+6veXyfdkvSVPalIg3OjAvYJ6JHuQpx3WGQ== X-Received: by 10.84.129.72 with SMTP id 66mr8433731plb.102.1504709400705; Wed, 06 Sep 2017 07:50:00 -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 h1sm3467646pfg.153.2017.09.06.07.49.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Sep 2017 07:49:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 6 Sep 2017 07:49:40 -0700 Message-Id: <20170906144940.30880-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170906144940.30880-1-richard.henderson@linaro.org> References: <20170906144940.30880-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::22d Subject: [Qemu-devel] [PULL 14/14] 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: peter.maydell@linaro.org, Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Acked-by: Cornelia Huck Signed-off-by: Richard Henderson --- tcg/s390/tcg-target.inc.c | 119 +++++++++++++++++----------------------------- 1 file changed, 43 insertions(+), 76 deletions(-) -- 2.13.5 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,