From patchwork Fri Oct 29 04:32:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 516401 Delivered-To: patch@linaro.org Received: by 2002:ad5:5208:0:0:0:0:0 with SMTP id p8csp402711iml; Thu, 28 Oct 2021 21:57:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdnQKT9ICqDx+Apa/mu3WfUMEBP+c/cXNIWjo/DuryJmeOqlGzQcymnTlmAYESm+9rqXsh X-Received: by 2002:aca:af4a:: with SMTP id y71mr1344825oie.28.1635483423886; Thu, 28 Oct 2021 21:57:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635483423; cv=none; d=google.com; s=arc-20160816; b=afOOu4Ma1OZjHSlliuhER5wj5q3507ZmDz8M9ynSCsgRHnXRd7SX5IJyke2HgEHqui q/Fn32yY+NmOkBmAfmepfi4iuyYs2j/rfcqU2XMgZyNK35L0+6DNCeRxY40dH/w+rrYu EOQR3TnUJVkmVZu7sBHyr5+OAtot/loWdSO1DoludE204lVBjBBqHQRJmtmlfugQblBD AFQJL7qfjP9Um55Jfx0I4MNMimCB1FnpdIo6tmbrv/TeuWGMfLq75KNjHHodoxYymtng 0DlMz4t6KDdIdpL7sJpYAgfQ6K+MVbhUacKf58Vw9VlbZjpF9M/q395/v7uHIukWawn/ cEGw== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=XCdKX5lGX4jVtgmDyFNtAjJPKoYBkr5rEDOGi0sGeW8=; b=cpyn8azUME6EVcaigxbWbWxnGZGSGdtaJ4Uj8A72M5/Br56Kmi51DkBeWJ/PW6R3sG M+IAlaHbqsE5Z8xpQqIsAkMzFkUuYpkfv+JBVuQY/OKljeCXcXoSDmEgowdqR349+VGF X0FWqPacP1sEcTeyEGf8D+7tO9FNWaRyRBAXTZfpjqaVf0J6YjL49Ld4AOmHX6XaV4r6 mR17SWC5jmjgPKT8SYrCHdQab6MJMUrXeqmpwcf3DIvxLXk6gN7ENwkHbexIrgV/b3tr QJY0euOKMvdciybAvYLB5pwA3W8EloRLl2LH0BvbR+J1PK7PqQDwrz/UYaKwUH4yNgV+ SR0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="GyML/K9Q"; 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 p8si6018268otk.50.2021.10.28.21.57.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Oct 2021 21:57:03 -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="GyML/K9Q"; 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]:36356 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mgJwt-0004eN-5A for patch@linaro.org; Fri, 29 Oct 2021 00:57:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51358) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mgJaY-0004WQ-66 for qemu-devel@nongnu.org; Fri, 29 Oct 2021 00:33:58 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]:44687) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mgJaT-0007yS-KV for qemu-devel@nongnu.org; Fri, 29 Oct 2021 00:33:57 -0400 Received: by mail-pl1-x633.google.com with SMTP id t11so5981152plq.11 for ; Thu, 28 Oct 2021 21:33:53 -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 :mime-version:content-transfer-encoding; bh=XCdKX5lGX4jVtgmDyFNtAjJPKoYBkr5rEDOGi0sGeW8=; b=GyML/K9QSeCKSmQmxTzJFXnYhcUb9xudW34bH9WuWIPd0UVVHWpUOBjqdK5X6mAFtd WQxHBzrWGC1ZU8lq28bDEeAqvIilHXCKkxC9VW5kNPqw3v3NSsZGlEzChA1FCIqr3Krb 3HvDqkhxDMYi1JqyGcPJTkhmMylo5TMEfmGbOgtwUKjJLLNwVrwn0c/aPXgDuYCNxQdI 8pcUeNHi8huwCOMe44bGAfdoyc2+OP7TWKUj6G6+ysPQ83FHRGHvrbjvjxOmOpYmlWq+ nTB098SIblEc0+7KIU+gB8MmzIy8uEc11w70UaBuMvv4YeuwBtJuYGZLhgYcHSQmwruW dp/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XCdKX5lGX4jVtgmDyFNtAjJPKoYBkr5rEDOGi0sGeW8=; b=M7wFsxHDsBnR49c9W0xZHdaZNmyIsuCd4H80nvRcy3kTHr8kyt9cI4q1ipmkiGDLnW InddSgiE4j/QAkZa0u4HOiqIueTh17H7RyZ0cTPpau2dUE73Z6yXMTPtJdb7XgWbQq4e 2nL/zh3/qr2fO5U55aLZ/LOK18aWiihnwLRNowW3xCjbABeFvnIQCcwgNCZl44RKvE0B aityBJwoPcUEP4YQkIxfkeTS7Xcz63SIBbA2MnImhZ+Tpmrn0Phr2+eXgPFmK+SMHv1k LUMMnRtbEYOIPEuE3lGrAjdgpbPu53SYjo273cRMA4V72Gt+c4fh/bCeiumgxYCClT12 WcSw== X-Gm-Message-State: AOAM5305HacgD7scnnT0Yv30ha5Jo9HlWTA3ni1329hNcl1XcKfcdE8o 0cVAYDaSWKTvivyhzR3fkU7TDgdcVsKzCw== X-Received: by 2002:a17:90b:4f4b:: with SMTP id pj11mr9144171pjb.4.1635482032437; Thu, 28 Oct 2021 21:33:52 -0700 (PDT) Received: from localhost.localdomain (174-21-75-75.tukw.qwest.net. [174.21.75.75]) by smtp.gmail.com with ESMTPSA id i11sm4120257pgp.18.2021.10.28.21.33.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Oct 2021 21:33:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL v2 26/60] tcg/optimize: Split out fold_addsub2_i32 Date: Thu, 28 Oct 2021 21:32:55 -0700 Message-Id: <20211029043329.1518029-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211029043329.1518029-1-richard.henderson@linaro.org> References: <20211029043329.1518029-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.google.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) 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_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Luis Pires , =?utf-8?q?Philippe_Mathieu-Da?= =?utf-8?q?ud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Add two additional helpers, fold_add2_i32 and fold_sub2_i32 which will not be simple wrappers forever. Reviewed-by: Luis Pires Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/optimize.c | 70 +++++++++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 26 deletions(-) -- 2.25.1 diff --git a/tcg/optimize.c b/tcg/optimize.c index 805522f99d..9d1d045363 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -704,6 +704,39 @@ static bool fold_add(OptContext *ctx, TCGOp *op) return fold_const2(ctx, op); } +static bool fold_addsub2_i32(OptContext *ctx, TCGOp *op, bool add) +{ + if (arg_is_const(op->args[2]) && arg_is_const(op->args[3]) && + arg_is_const(op->args[4]) && arg_is_const(op->args[5])) { + uint32_t al = arg_info(op->args[2])->val; + uint32_t ah = arg_info(op->args[3])->val; + uint32_t bl = arg_info(op->args[4])->val; + uint32_t bh = arg_info(op->args[5])->val; + uint64_t a = ((uint64_t)ah << 32) | al; + uint64_t b = ((uint64_t)bh << 32) | bl; + TCGArg rl, rh; + TCGOp *op2 = tcg_op_insert_before(ctx->tcg, op, INDEX_op_mov_i32); + + if (add) { + a += b; + } else { + a -= b; + } + + rl = op->args[0]; + rh = op->args[1]; + tcg_opt_gen_movi(ctx, op, rl, (int32_t)a); + tcg_opt_gen_movi(ctx, op2, rh, (int32_t)(a >> 32)); + return true; + } + return false; +} + +static bool fold_add2_i32(OptContext *ctx, TCGOp *op) +{ + return fold_addsub2_i32(ctx, op, true); +} + static bool fold_and(OptContext *ctx, TCGOp *op) { return fold_const2(ctx, op); @@ -1056,6 +1089,11 @@ static bool fold_sub(OptContext *ctx, TCGOp *op) return fold_const2(ctx, op); } +static bool fold_sub2_i32(OptContext *ctx, TCGOp *op) +{ + return fold_addsub2_i32(ctx, op, false); +} + static bool fold_xor(OptContext *ctx, TCGOp *op) { return fold_const2(ctx, op); @@ -1701,32 +1739,6 @@ void tcg_optimize(TCGContext *s) } break; - case INDEX_op_add2_i32: - case INDEX_op_sub2_i32: - if (arg_is_const(op->args[2]) && arg_is_const(op->args[3]) - && arg_is_const(op->args[4]) && arg_is_const(op->args[5])) { - uint32_t al = arg_info(op->args[2])->val; - uint32_t ah = arg_info(op->args[3])->val; - uint32_t bl = arg_info(op->args[4])->val; - uint32_t bh = arg_info(op->args[5])->val; - uint64_t a = ((uint64_t)ah << 32) | al; - uint64_t b = ((uint64_t)bh << 32) | bl; - TCGArg rl, rh; - TCGOp *op2 = tcg_op_insert_before(s, op, INDEX_op_mov_i32); - - if (opc == INDEX_op_add2_i32) { - a += b; - } else { - a -= b; - } - - rl = op->args[0]; - rh = op->args[1]; - tcg_opt_gen_movi(&ctx, op, rl, (int32_t)a); - tcg_opt_gen_movi(&ctx, op2, rh, (int32_t)(a >> 32)); - continue; - } - break; default: break; @@ -1737,6 +1749,9 @@ void tcg_optimize(TCGContext *s) CASE_OP_32_64_VEC(add): done = fold_add(&ctx, op); break; + case INDEX_op_add2_i32: + done = fold_add2_i32(&ctx, op); + break; CASE_OP_32_64_VEC(and): done = fold_and(&ctx, op); break; @@ -1833,6 +1848,9 @@ void tcg_optimize(TCGContext *s) CASE_OP_32_64_VEC(sub): done = fold_sub(&ctx, op); break; + case INDEX_op_sub2_i32: + done = fold_sub2_i32(&ctx, op); + break; CASE_OP_32_64_VEC(xor): done = fold_xor(&ctx, op); break;