From patchwork Fri Oct 29 04:33:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 516427 Delivered-To: patch@linaro.org Received: by 2002:ad5:5208:0:0:0:0:0 with SMTP id p8csp425250iml; Thu, 28 Oct 2021 22:28:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxL8HE2Ye8EmhGjT26EHpxz168e+7jY3rUVE7y1lESdqIXXwhfDVReP3+R60MxDth4WFojC X-Received: by 2002:a05:6808:1cc:: with SMTP id x12mr11846225oic.88.1635485303892; Thu, 28 Oct 2021 22:28:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635485303; cv=none; d=google.com; s=arc-20160816; b=pifqdbCwxxrIPMzxIeiFqAL3M7XCudKA+xduuX7/A97gaBq9wWUKn9Bz1I/pKCe4FG 2goKoDH8YH+DjsddMQVEO5kYe0G6D5M7BpiQHBa6xIySue+7JCBs9HZnyaSZDVQ+14H3 UORFAqJc8Y92Z96iKA34pipaq7LFspLxcRtwxVtMBO+TTFF+e/LwjuZnmL/7n/8Nbx9F UOheeSLKxosVIC4g7+dsgOiaZhBLz2O2I5y3+qrFlTVjvRCXXH6aiaHqwCIHFoYndnhx jBG1Mlcd+RnRWH5khz0RK36r3yjwXJdTb5yrCSMXM8mSdMVWyXtHo5FSRnTcaItYG5v9 lOkg== 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=jRRRP6JmvKBpZ0VJ9BwC7heQ6m7xhbcAt+61FCJAiek=; b=TcIo6J+Zxn/XrvoRKBupseFA2EEjUeOf9BuvnIrnzfoy14IiscHcVHeYKo7ikqoaSC Omx9oPu7doVf0SAyJBxaF48wUX635J437MTEWtRZiwLytzV0Dz9E9sYbmnHbvxHZxyDe LYWn2lcXoznYnR2o/1uwFcRwydFsma6gozD8exl+pdAgrbqDx/HkjI0iZzr2221BSgRN wYACRvHQYb9B0UCbBPxXQ6cd+WXx6WOkukBE/6AgtGnPnBPbl8EC7SUiMvAakQ7bj3SG uWtaixQWfVEaTQsOu7EuTiGJSaFtZP8ttcIgLo5/yDCcUj74KM2KOEpLDavwTO3//hg6 QwFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DrZqEtGH; 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 d10si4797900oth.162.2021.10.28.22.28.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Oct 2021 22:28:23 -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=DrZqEtGH; 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]:36412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mgKRD-0001qg-6N for patch@linaro.org; Fri, 29 Oct 2021 01:28:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52114) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mgJdl-0002UO-0U for qemu-devel@nongnu.org; Fri, 29 Oct 2021 00:37:17 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]:43896) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mgJdd-0000MA-9d for qemu-devel@nongnu.org; Fri, 29 Oct 2021 00:37:15 -0400 Received: by mail-pg1-x534.google.com with SMTP id b4so1648490pgh.10 for ; Thu, 28 Oct 2021 21:37:07 -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=jRRRP6JmvKBpZ0VJ9BwC7heQ6m7xhbcAt+61FCJAiek=; b=DrZqEtGH51bOeA5e2RNtplZ3Mp9JKjLtxHXI7uPRq/uyP04fvv/cYdN5V/Uj67xH+F QyDOB+OZSyRdIwuFkUYl3le9GJ/F2xoBeaezM3c6UduQkW/Pb0S32KRKXAgRvh0kjodH toczkiLIgfcf6lxsabmFP+QTJH+ASkljq/CGUKKmkZWqc7J45ILep1JqVd/iZK7WuRBc PA1vKPh48jaO7O2N/TQFrlrsgP1rOyrKa8kiexl2f012pEodAzKH8nHG1MDaU8vuyrfu laTvyu2XdczMPIKfoHdAexyW9L3iSkUYePAvV4gw3QuywSPaGNdBSHc+3NaZAGhfRBOO vorw== 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=jRRRP6JmvKBpZ0VJ9BwC7heQ6m7xhbcAt+61FCJAiek=; b=q2iuK/0rD/yJghO77ObQROlasOQHKDji15v3IjDcGUczxr8QqSn3nohVf2Y4l+vnZ4 QOgAUZSSW3+Zfgi7z+AJ7L0Ab4rLJoIha9TPPCxZzgtab20UIBgBe6peg7IoGwI11Y4a dDStsmg14Gd1hzFGqrVPwKgn0MPo7hvgrFaLXhvaiee2RpSfiYrl7NAw4j8f4pnzy2zk KlexiPC6e3VohT9xH81lC0lqVkGNky9Lb+3miNIcaBVa+twoipmys3iJfqR9/ISnJ5xG Jm9HXohYzojXCwAshLxqYtAmLqfVCA+loVyQCS+xcBNZCNY+5L4EKw1VrWdTl6S3q8Rg i7XA== X-Gm-Message-State: AOAM530Zq0WwxRcqVxH+HTraC50n2J71VmGrqhjSYqWnCOwxMI77K+wT pjS9kGC5tPs8aCOQVeUEp14/cubJJF9hjw== X-Received: by 2002:a63:1c03:: with SMTP id c3mr6440217pgc.207.1635482226928; Thu, 28 Oct 2021 21:37:06 -0700 (PDT) Received: from localhost.localdomain (174-21-75-75.tukw.qwest.net. [174.21.75.75]) by smtp.gmail.com with ESMTPSA id b8sm5228232pfv.56.2021.10.28.21.37.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Oct 2021 21:37:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL v2 44/60] tcg/optimize: Expand fold_mulu2_i32 to all 4-arg multiplies Date: Thu, 28 Oct 2021 21:33:13 -0700 Message-Id: <20211029043329.1518029-45-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::534; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x534.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_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" Rename to fold_multiply2, and handle muls2_i32, mulu2_i64, and muls2_i64. Reviewed-by: Luis Pires Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/optimize.c | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) -- 2.25.1 diff --git a/tcg/optimize.c b/tcg/optimize.c index e84d10be53..e2ecad2884 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1412,19 +1412,44 @@ static bool fold_mul_highpart(OptContext *ctx, TCGOp *op) return false; } -static bool fold_mulu2_i32(OptContext *ctx, TCGOp *op) +static bool fold_multiply2(OptContext *ctx, TCGOp *op) { if (arg_is_const(op->args[2]) && arg_is_const(op->args[3])) { - uint32_t a = arg_info(op->args[2])->val; - uint32_t b = arg_info(op->args[3])->val; - uint64_t r = (uint64_t)a * b; + uint64_t a = arg_info(op->args[2])->val; + uint64_t b = arg_info(op->args[3])->val; + uint64_t h, l; TCGArg rl, rh; - TCGOp *op2 = tcg_op_insert_before(ctx->tcg, op, INDEX_op_mov_i32); + TCGOp *op2; + + switch (op->opc) { + case INDEX_op_mulu2_i32: + l = (uint64_t)(uint32_t)a * (uint32_t)b; + h = (int32_t)(l >> 32); + l = (int32_t)l; + break; + case INDEX_op_muls2_i32: + l = (int64_t)(int32_t)a * (int32_t)b; + h = l >> 32; + l = (int32_t)l; + break; + case INDEX_op_mulu2_i64: + mulu64(&l, &h, a, b); + break; + case INDEX_op_muls2_i64: + muls64(&l, &h, a, b); + break; + default: + g_assert_not_reached(); + } rl = op->args[0]; rh = op->args[1]; - tcg_opt_gen_movi(ctx, op, rl, (int32_t)r); - tcg_opt_gen_movi(ctx, op2, rh, (int32_t)(r >> 32)); + + /* The proper opcode is supplied by tcg_opt_gen_mov. */ + op2 = tcg_op_insert_before(ctx->tcg, op, 0); + + tcg_opt_gen_movi(ctx, op, rl, l); + tcg_opt_gen_movi(ctx, op2, rh, h); return true; } return false; @@ -1932,8 +1957,9 @@ void tcg_optimize(TCGContext *s) CASE_OP_32_64(muluh): done = fold_mul_highpart(&ctx, op); break; - case INDEX_op_mulu2_i32: - done = fold_mulu2_i32(&ctx, op); + CASE_OP_32_64(muls2): + CASE_OP_32_64(mulu2): + done = fold_multiply2(&ctx, op); break; CASE_OP_32_64(nand): done = fold_nand(&ctx, op);