From patchwork Fri Oct 21 07:29:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617144 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp822977pvb; Fri, 21 Oct 2022 01:38:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6R5HoX7o2AAGSj8byORmWm2WkDxwcR3/C6tpwfCOFfTSGBU/3QyKyv/UUsSjKZo03zv3p9 X-Received: by 2002:a05:622a:101:b0:39c:e5c7:71cd with SMTP id u1-20020a05622a010100b0039ce5c771cdmr15386077qtw.387.1666341494721; Fri, 21 Oct 2022 01:38:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666341494; cv=none; d=google.com; s=arc-20160816; b=j25069QLgJBlVOC3FxJTFTtK3Ee7immmKQjD05x911f4YSWwCcvvdCR3cjMcAToPup kv+/9d1y3Dvb+s+ywFdJn/j4gcp1EYEogcXpnoFcEFH3+H5Xa3atD50S2JYQ3po8fz6x xEz//JAo4v1UqgvqwqTh0Bz8tsgf2ipP8bvxFcFb+hxLxn6g24xopyz3SUCSnZI/tVyn e2ATdo9gkvR5Gpcl5mB59ZXTX3tDZpTzQmYkVoG7TWRpd5aqk/P2SjR2mKbWwTJGiGcI ZhStbMhs0t9Uht8FGyho3GDvOv5r8Zk0Iur+LTT7G9pI76jGxvTGmVeeBkQDLuHlYimi IReg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=j3xi1EBD8jK1qsnUY3LZUu6R47blhBME7MEkkZGVfDU=; b=IS3VDAw1fGBJDu6UFiSEV0J2vX8UmjBwlzWBl1nJ1il+Mah3VoAITutcUNjIgLDnNw ZsAPrOUP9wEWQk/H5yO7osbhrllxlNJHIGKhzFbBMIQH1G5nJA//0EOBAEVZvvW1FLTp 4vh+mB9OLbISpgHlfjt1teMa7FtzATCdzIA7uT4aDFGy8jS68md/S92vw273IPdxtNjJ wW3qJyi1YlgInu8zJAYB+U8f665xxsm12GuwKC9g9A1aZGIldNcz9gT/4Ea+zYQetkTL QUoingShh98R/uoNUMzqii3MG4UhL5sceYTANln+jFeVEqpfGtvrHCtU7oLnUYEhu2K4 lvPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Bx+4oD+D; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id kd15-20020a056214400f00b004af8fca03b8si10210185qvb.519.2022.10.21.01.38.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 01:38:14 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Bx+4oD+D; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olnXg-0006eU-F0 for patch@linaro.org; Fri, 21 Oct 2022 04:38:14 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmVK-0004Ug-1h for patch@linaro.org; Fri, 21 Oct 2022 03:31:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmUj-00044o-DW for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:31:12 -0400 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olmUS-0007rE-CP for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:31:05 -0400 Received: by mail-pj1-x1035.google.com with SMTP id g8-20020a17090a128800b0020c79f987ceso5861088pja.5 for ; Fri, 21 Oct 2022 00:30:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=j3xi1EBD8jK1qsnUY3LZUu6R47blhBME7MEkkZGVfDU=; b=Bx+4oD+Dg9v3/SUwtvhJZI+jyAsgg4vs+TW+Zxa8Rqh0RIzYBl8iNQws8jQkJHRQDz YOgJ42HNokl2rOIFew57HH4szSfzInAtbFHFUNvlthUJey4oO4cfTiH/my6tw8/43Y9R 5Gc2N/k0KKF4A2/4r8t7p/zPme5nTim6MHzT0BEC8AOl1St4zVhW2paSAfZh6HW37BKF W9rR4Ybaatenad4UEaa2Yfi1K4sjUr2WKEOn6ERK8i6fOAC7m1+v36S6gSzF7WQU3nxS UKK0PaOTVr7IFawCuOw/kZrS/+GoT7YL3IxCO5/UXI9E4yJEeR4hNSb6pFPhGrJ6iGFB XLiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=j3xi1EBD8jK1qsnUY3LZUu6R47blhBME7MEkkZGVfDU=; b=xlqVQY4okWunsXgLtRfvf1yfpsKRwci3gmQFuZtUSaZtNgzh0CL2yl5DhHMybhsfYG NyZTlRplGyuduowO1EH/jgFZyEncL7+0c3GI9EfZEbeSASM/rPsUwx9eRZ3UYZXR1iPL gIZNCmCzEJi/BgtZfrsrYmMZRoD4Vm/3OE5YhH/A6dIJk79iaOBzpNieLT3newuK3Q5U 8wwuokiiu4vLZN4XbUupSQ+JbVRyewAQ4jS1gM/GhneuAQYDmMCvgahnD2KRZ9o4tm9x NIoB92qERaz38kQmwFDZ1+Fm3OChPWlHFUNtBPCplYIXPej3fLwDaHlN46JSd+8D6++P cfuA== X-Gm-Message-State: ACrzQf0PTjLx5GXLEAy1YdAvsAVq16yEm8UVobAB7+WmUIRdqxxwSvKP VPy8zjQA7LeLGD+Nw3V54sdM8reCbfas2mbn X-Received: by 2002:a17:90b:4b02:b0:20c:c3a8:38d with SMTP id lx2-20020a17090b4b0200b0020cc3a8038dmr54057347pjb.12.1666337446507; Fri, 21 Oct 2022 00:30:46 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id a9-20020a17090a6d8900b002008d0e5cb5sm1042721pjk.47.2022.10.21.00.30.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:30:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org Subject: [PATCH 1/9] target/s390x: Use a single return for helper_divs32/u32 Date: Fri, 21 Oct 2022 17:29:58 +1000 Message-Id: <20221021073006.2398819-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021073006.2398819-1-richard.henderson@linaro.org> References: <20221021073006.2398819-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1035.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Pack the quotient and remainder into a single uint64_t. Signed-off-by: Richard Henderson Acked-by: Ilya Leoshkevich Reviewed-by: Philippe Mathieu-Daudé --- target/s390x/helper.h | 2 +- target/s390x/tcg/int_helper.c | 26 +++++++++++++------------- target/s390x/tcg/translate.c | 10 ++++++---- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/target/s390x/helper.h b/target/s390x/helper.h index bf33d86f74..97a9668eef 100644 --- a/target/s390x/helper.h +++ b/target/s390x/helper.h @@ -10,7 +10,7 @@ DEF_HELPER_FLAGS_4(clc, TCG_CALL_NO_WG, i32, env, i32, i64, i64) DEF_HELPER_3(mvcl, i32, env, i32, i32) DEF_HELPER_3(clcl, i32, env, i32, i32) DEF_HELPER_FLAGS_4(clm, TCG_CALL_NO_WG, i32, env, i32, i32, i64) -DEF_HELPER_FLAGS_3(divs32, TCG_CALL_NO_WG, s64, env, s64, s64) +DEF_HELPER_FLAGS_3(divs32, TCG_CALL_NO_WG, i64, env, s64, s64) DEF_HELPER_FLAGS_3(divu32, TCG_CALL_NO_WG, i64, env, i64, i64) DEF_HELPER_FLAGS_3(divs64, TCG_CALL_NO_WG, s64, env, s64, s64) DEF_HELPER_FLAGS_4(divu64, TCG_CALL_NO_WG, i64, env, i64, i64, i64) diff --git a/target/s390x/tcg/int_helper.c b/target/s390x/tcg/int_helper.c index 954542388a..130b8bd4d2 100644 --- a/target/s390x/tcg/int_helper.c +++ b/target/s390x/tcg/int_helper.c @@ -34,45 +34,45 @@ #endif /* 64/32 -> 32 signed division */ -int64_t HELPER(divs32)(CPUS390XState *env, int64_t a, int64_t b64) +uint64_t HELPER(divs32)(CPUS390XState *env, int64_t a, int64_t b64) { - int32_t ret, b = b64; - int64_t q; + int32_t b = b64; + int64_t q, r; if (b == 0) { tcg_s390_program_interrupt(env, PGM_FIXPT_DIVIDE, GETPC()); } - ret = q = a / b; - env->retxl = a % b; + q = a / b; + r = a % b; /* Catch non-representable quotient. */ - if (ret != q) { + if (q != (int32_t)q) { tcg_s390_program_interrupt(env, PGM_FIXPT_DIVIDE, GETPC()); } - return ret; + return deposit64(r, 32, 32, q); } /* 64/32 -> 32 unsigned division */ uint64_t HELPER(divu32)(CPUS390XState *env, uint64_t a, uint64_t b64) { - uint32_t ret, b = b64; - uint64_t q; + uint32_t b = b64; + uint64_t q, r; if (b == 0) { tcg_s390_program_interrupt(env, PGM_FIXPT_DIVIDE, GETPC()); } - ret = q = a / b; - env->retxl = a % b; + q = a / b; + r = a % b; /* Catch non-representable quotient. */ - if (ret != q) { + if (q != (uint32_t)q) { tcg_s390_program_interrupt(env, PGM_FIXPT_DIVIDE, GETPC()); } - return ret; + return deposit64(r, 32, 32, q); } /* 64/64 -> 64 signed division */ diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c index 1d2dddab1c..525317c9df 100644 --- a/target/s390x/tcg/translate.c +++ b/target/s390x/tcg/translate.c @@ -2395,15 +2395,17 @@ static DisasJumpType op_diag(DisasContext *s, DisasOps *o) static DisasJumpType op_divs32(DisasContext *s, DisasOps *o) { - gen_helper_divs32(o->out2, cpu_env, o->in1, o->in2); - return_low128(o->out); + gen_helper_divs32(o->out, cpu_env, o->in1, o->in2); + tcg_gen_ext32u_i64(o->out2, o->out); + tcg_gen_shri_i64(o->out, o->out, 32); return DISAS_NEXT; } static DisasJumpType op_divu32(DisasContext *s, DisasOps *o) { - gen_helper_divu32(o->out2, cpu_env, o->in1, o->in2); - return_low128(o->out); + gen_helper_divu32(o->out, cpu_env, o->in1, o->in2); + tcg_gen_ext32u_i64(o->out2, o->out); + tcg_gen_shri_i64(o->out, o->out, 32); return DISAS_NEXT; }