{"id":810655,"url":"http://patchwork.ozlabs.org/api/patches/810655/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20170906144940.30880-15-richard.henderson@linaro.org/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170906144940.30880-15-richard.henderson@linaro.org>","list_archive_url":null,"date":"2017-09-06T14:49:40","name":"[PULL,14/14] tcg/s390: Use slbgr for setcond le and leu","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"bb5192d1f6207f15757d9bcdc076aa582845c2d1","submitter":{"id":72104,"url":"http://patchwork.ozlabs.org/api/people/72104/?format=json","name":"Richard Henderson","email":"richard.henderson@linaro.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20170906144940.30880-15-richard.henderson@linaro.org/mbox/","series":[{"id":1829,"url":"http://patchwork.ozlabs.org/api/series/1829/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=1829","date":"2017-09-06T14:49:28","name":"[PULL,01/14] tcg: Remove support for ia64 as host","version":1,"mbox":"http://patchwork.ozlabs.org/series/1829/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/810655/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/810655/checks/","tags":{},"related":[],"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"j93xauiE\"; dkim-atps=neutral"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xnRTz4W2Qz9s7C\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu,  7 Sep 2017 00:55:51 +1000 (AEST)","from localhost ([::1]:36547 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dpbk4-0001dC-EZ\n\tfor incoming@patchwork.ozlabs.org; Wed, 06 Sep 2017 10:55:48 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:40121)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <richard.henderson@linaro.org>) id 1dpbea-0005en-Ko\n\tfor qemu-devel@nongnu.org; Wed, 06 Sep 2017 10:50:11 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <richard.henderson@linaro.org>) id 1dpbeU-0000SR-FX\n\tfor qemu-devel@nongnu.org; Wed, 06 Sep 2017 10:50:08 -0400","from mail-pf0-x22d.google.com ([2607:f8b0:400e:c00::22d]:36792)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)\n\t(Exim 4.71) (envelope-from <richard.henderson@linaro.org>)\n\tid 1dpbeU-0000S4-7s\n\tfor qemu-devel@nongnu.org; Wed, 06 Sep 2017 10:50:02 -0400","by mail-pf0-x22d.google.com with SMTP id e199so13133570pfh.3\n\tfor <qemu-devel@nongnu.org>; Wed, 06 Sep 2017 07:50:02 -0700 (PDT)","from bigtime.twiddle.net (97-126-108-236.tukw.qwest.net.\n\t[97.126.108.236]) by smtp.gmail.com with ESMTPSA id\n\th1sm3467646pfg.153.2017.09.06.07.49.59\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tWed, 06 Sep 2017 07:49:59 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=pyrCD0X5hMABEfynCC0ORcitRg8eEvaZTchNZ88dfPM=;\n\tb=j93xauiEQK4tZCAQAtxwQ5Mw2EiZym6rkBPJ8FM8C4J/MAo/tZNR4nva6wXLe7VTZ6\n\tbpGXSruwrjlbF+KxJUHFw8D/yYQtvPse+g6a0Dh27+L1WEiBHBQctkUZn2yVM4RbggBn\n\tV8CzaQlTGEaioCghJuBlFPwcFHDJwtH7rQ8XE=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=pyrCD0X5hMABEfynCC0ORcitRg8eEvaZTchNZ88dfPM=;\n\tb=pnCVXmiTCFGNGH95tWqMXRy6M8GtJrc3wfNJAeT/bedP2u23KZgIn/+XS0I5AU/H0A\n\tW/UXOB9DvciHykZIGZpe6jm7RV7jgW0z55oEcqkM1LwZqpewB9f9LB39ijx9myZs4fV+\n\tJPpkcdC0pw4c9TdCP8Um88lDAyBhn4PoDtmmcXOuHrh8yi1k+cTO2MNZrlDUceUgcqVS\n\totASqkHyuZkO105rZN2jawM6dLd67J7whOCEkVnzvW7j3dSIs6TERd1THy+Xj7gR901c\n\tfuA3HA3U0LXkn1M5/kLxrzuiITvhhQ6lVMQVZm+7Om5ye7wDfxeOpZFjSM7guDN+0pcO\n\tpLSQ==","X-Gm-Message-State":"AHPjjUi1ogVncwJK7XXJAnQ3n5cdEyoDhJKQDTpN8PGQitbTozlZeEiO\n\t2Zp3kfsqrR5d2mD9gOWqjw==","X-Google-Smtp-Source":"ADKCNb5UdTCm89z0TWiIlymUurd0AH9MBww2STj/tDo+6veXyfdkvSVPalIg3OjAvYJ6JHuQpx3WGQ==","X-Received":"by 10.84.129.72 with SMTP id 66mr8433731plb.102.1504709400705;\n\tWed, 06 Sep 2017 07:50:00 -0700 (PDT)","From":"Richard Henderson <richard.henderson@linaro.org>","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\n\trecognized.","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":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"peter.maydell@linaro.org, Richard Henderson <rth@twiddle.net>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"},"content":"From: Richard Henderson <rth@twiddle.net>\n\nAcked-by: Cornelia Huck <cohuck@redhat.com>\nSigned-off-by: Richard Henderson <rth@twiddle.net>\n---\n tcg/s390/tcg-target.inc.c | 119 +++++++++++++++++-----------------------------\n 1 file changed, 43 insertions(+), 76 deletions(-)","diff":"diff --git a/tcg/s390/tcg-target.inc.c b/tcg/s390/tcg-target.inc.c\nindex 0de968fde2..38b9e791ee 100644\n--- a/tcg/s390/tcg-target.inc.c\n+++ b/tcg/s390/tcg-target.inc.c\n@@ -1084,11 +1084,20 @@ static void tgen_setcond(TCGContext *s, TCGType type, TCGCond cond,\n \n     have_loc = (s390_facilities & FACILITY_LOAD_ON_COND) != 0;\n \n-    /* For HAVE_LOC, only the path through do_greater is smaller.  */\n+    /* For HAVE_LOC, only the paths through GTU/GT/LEU/LE are smaller.  */\n+ restart:\n     switch (cond) {\n+    case TCG_COND_NE:\n+        /* X != 0 is X > 0.  */\n+        if (c2const && c2 == 0) {\n+            cond = TCG_COND_GTU;\n+        } else {\n+            break;\n+        }\n+        /* fallthru */\n+\n     case TCG_COND_GTU:\n     case TCG_COND_GT:\n-    do_greater:\n         /* The result of a compare has CC=2 for GT and CC=3 unused.\n            ADD LOGICAL WITH CARRY considers (CC & 2) the carry bit.  */\n         tgen_cmp(s, type, cond, c1, c2, c2const, true);\n@@ -1096,49 +1105,33 @@ static void tgen_setcond(TCGContext *s, TCGType type, TCGCond cond,\n         tcg_out_insn(s, RRE, ALCGR, dest, dest);\n         return;\n \n-    case TCG_COND_GEU:\n-        if (have_loc) {\n-            goto do_loc;\n-        }\n-    do_geu:\n-        /* We need \"real\" carry semantics, so use SUBTRACT LOGICAL\n-           instead of COMPARE LOGICAL.  This may need an extra move.  */\n-        if (c2const) {\n-            tcg_out_mov(s, type, TCG_TMP0, c1);\n-            if (type == TCG_TYPE_I32) {\n-                tcg_out_insn(s, RIL, SLFI, TCG_TMP0, c2);\n-            } else {\n-                tcg_out_insn(s, RIL, SLGFI, TCG_TMP0, c2);\n-            }\n-        } else if (s390_facilities & FACILITY_DISTINCT_OPS) {\n-            if (type == TCG_TYPE_I32) {\n-                tcg_out_insn(s, RRF, SLRK, TCG_TMP0, c1, c2);\n-            } else {\n-                tcg_out_insn(s, RRF, SLGRK, TCG_TMP0, c1, c2);\n-            }\n+    case TCG_COND_EQ:\n+        /* X == 0 is X <= 0.  */\n+        if (c2const && c2 == 0) {\n+            cond = TCG_COND_LEU;\n         } else {\n-            tcg_out_mov(s, type, TCG_TMP0, c1);\n-            if (type == TCG_TYPE_I32) {\n-                tcg_out_insn(s, RR, SLR, TCG_TMP0, c2);\n-            } else {\n-                tcg_out_insn(s, RRE, SLGR, TCG_TMP0, c2);\n-            }\n+            break;\n         }\n-        tcg_out_movi(s, TCG_TYPE_I64, dest, 0);\n-        tcg_out_insn(s, RRE, ALCGR, dest, dest);\n-        return;\n+        /* fallthru */\n \n     case TCG_COND_LEU:\n-        if (have_loc) {\n-            goto do_loc;\n-        }\n-        /* fallthru */\n+    case TCG_COND_LE:\n+        /* As above, but we're looking for borrow, or !carry.\n+           The second insn computes d - d - borrow, or -1 for true\n+           and 0 for false.  So we must mask to 1 bit afterward.  */\n+        tgen_cmp(s, type, cond, c1, c2, c2const, true);\n+        tcg_out_insn(s, RRE, SLBGR, dest, dest);\n+        tgen_andi(s, type, dest, 1);\n+        return;\n+\n+    case TCG_COND_GEU:\n     case TCG_COND_LTU:\n     case TCG_COND_LT:\n-        /* Swap operands so that we can use GEU/GTU/GT.  */\n+    case TCG_COND_GE:\n+        /* Swap operands so that we can use LEU/GTU/GT/LE.  */\n         if (c2const) {\n             if (have_loc) {\n-                goto do_loc;\n+                break;\n             }\n             tcg_out_movi(s, type, TCG_TMP0, c2);\n             c2 = c1;\n@@ -1149,51 +1142,25 @@ static void tgen_setcond(TCGContext *s, TCGType type, TCGCond cond,\n             c1 = c2;\n             c2 = t;\n         }\n-        if (cond == TCG_COND_LEU) {\n-            goto do_geu;\n-        }\n         cond = tcg_swap_cond(cond);\n-        goto do_greater;\n-\n-    case TCG_COND_NE:\n-        /* X != 0 is X > 0.  */\n-        if (c2const && c2 == 0) {\n-            cond = TCG_COND_GTU;\n-            goto do_greater;\n-        }\n-        break;\n-\n-    case TCG_COND_EQ:\n-        if (have_loc) {\n-            goto do_loc;\n-        }\n-        /* X == 0 is X <= 0 is 0 >= X.  */\n-        if (c2const && c2 == 0) {\n-            tcg_out_movi(s, TCG_TYPE_I64, TCG_TMP0, 0);\n-            c2 = c1;\n-            c2const = 0;\n-            c1 = TCG_TMP0;\n-            goto do_geu;\n-        }\n-        break;\n+        goto restart;\n \n     default:\n-        break;\n+        g_assert_not_reached();\n     }\n \n     cc = tgen_cmp(s, type, cond, c1, c2, c2const, false);\n-    /* Emit: d = 1; if (cc) goto over; d = 0; over:  */\n-    tcg_out_movi(s, type, dest, 1);\n-    tcg_out_insn(s, RI, BRC, cc, (4 + 4) >> 1);\n-    tcg_out_movi(s, type, dest, 0);\n-    return;\n-\n- do_loc:\n-    cc = tgen_cmp(s, type, cond, c1, c2, c2const, false);\n-    /* Emit: d = 0, t = 1, d = (cc ? t : d).  */\n-    tcg_out_movi(s, TCG_TYPE_I64, dest, 0);\n-    tcg_out_movi(s, TCG_TYPE_I64, TCG_TMP0, 1);\n-    tcg_out_insn(s, RRF, LOCGR, dest, TCG_TMP0, cc);\n+    if (have_loc) {\n+        /* Emit: d = 0, t = 1, d = (cc ? t : d).  */\n+        tcg_out_movi(s, TCG_TYPE_I64, dest, 0);\n+        tcg_out_movi(s, TCG_TYPE_I64, TCG_TMP0, 1);\n+        tcg_out_insn(s, RRF, LOCGR, dest, TCG_TMP0, cc);\n+    } else {\n+        /* Emit: d = 1; if (cc) goto over; d = 0; over:  */\n+        tcg_out_movi(s, type, dest, 1);\n+        tcg_out_insn(s, RI, BRC, cc, (4 + 4) >> 1);\n+        tcg_out_movi(s, type, dest, 0);\n+    }\n }\n \n static void tgen_movcond(TCGContext *s, TCGType type, TCGCond c, TCGReg dest,\n","prefixes":["PULL","14/14"]}