From patchwork Sun Dec 22 16:24:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 852954 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp3037086wrq; Sun, 22 Dec 2024 08:33:51 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWrh9eySje88OO83K2r8ssmlqdAGinoY8OlNfT2nvrmdtDzxupyojN4j7JvrdeI7n11DdogVQ==@linaro.org X-Google-Smtp-Source: AGHT+IHxP+cpGfJc7AJ5VlTFxf3tqK4kc7noZwWE5rA7UPEHFnV2TvIDE3nzAgSFGDF0BJfL7Oat X-Received: by 2002:a05:622a:110b:b0:467:603d:1cd5 with SMTP id d75a77b69052e-46a4b1a90e5mr173383001cf.26.1734885230824; Sun, 22 Dec 2024 08:33:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734885230; cv=none; d=google.com; s=arc-20240605; b=bvCAbU3/ocaeL3Mq3PaCu94ltJ+EjzjKj5bAFs6ov2P3i7M6wEgxg5SpO1ryo/mBuF 3Ia/JRZb4/ieRhrkqK7Uis4aCTENida9pKwUlIRwHIwuKFT/1c/Tjm/6ztp06oWIRhRo tu2afoPgf4sSMPPoDl+bPP8ql2CtUGNLe650KaqXLnErgoSjsvPZqkyIqf/uXWkeilj7 QlLn7Z/yMTRcacsDj7YpHRQ4PuUzfXjwTRiy6Votd8qhd9p/cLlv9Y14foxJ+e9odYpV ge18gjYuVLcGKiCU8Vh012EC580OlVyOW1IdCKAM3lGag5e2HgziNYCKV0SNHrYeiZYN i1Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=ctuXEQAvjhmDIIWoKLKBiMc6mMChQIOixW2dzl2+Gwk=; fh=vm85eyWrvOAHduw3sqEA+cYBqvHB7M0MHFcRJg7VWOo=; b=a73dhM/tKu7JKESdbFHBuXeOCLKr0/LYhzzhyQmO+QjCdyuffUfqyfai8Ammco+sgG au0ZgP7bK+pFxN+V32ZvJcCjY9IcDlsDGaqWIQNX2avqP2DH4eSFDctg9keadF2cExdR SSCGa/AbApPBBY/b092/YMuX8koxWfMSq+buquWOc7cD/5520rVl1fCaUtUQCIfTeT3c 8QbxkFU9SxGSwfmwh76//8hFtON78JxY89+O6xDFqyIAX11OBbB/q3MKITAeyu/W139A GHUlVxkVVakUto0ZmYvSmGRtAt/sXbVaNbplDs1x9+QSSfHwPsgjGcMohYVM9EkQt3wE LqyQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QCmWUtg0; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-46a3e531835si94732151cf.0.2024.12.22.08.33.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Dec 2024 08:33:50 -0800 (PST) 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=QCmWUtg0; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tPOpd-0005YX-AS; Sun, 22 Dec 2024 11:29:29 -0500 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 1tPOod-00051q-0s for qemu-devel@nongnu.org; Sun, 22 Dec 2024 11:28:29 -0500 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tPOoa-0003kH-7V for qemu-devel@nongnu.org; Sun, 22 Dec 2024 11:28:26 -0500 Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-801c8164ef9so2478836a12.1 for ; Sun, 22 Dec 2024 08:28:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734884903; x=1735489703; darn=nongnu.org; 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=ctuXEQAvjhmDIIWoKLKBiMc6mMChQIOixW2dzl2+Gwk=; b=QCmWUtg0tyudFV35HYJc6rG9HTN7pJib/L4uu1iCDt74hvwEynPEzEyfQioUhmRUdm lMoFDxDcog3Lt+vBI6QiA58RJyM6p9CfOWVtwyP5Vz5TPJIzqZPsWcjgUjKFCQx5xNIN Xiv7bPlQ1txBJeRebmgIbiZKubLey/n9A1ET+4vYD8hmMfnEoa/nAJNSkpVXCw4ZG39J RNL+IlaDInfXRH9uQxCtbK8sM5acp7irYemp0lr/3cH1xI3WgXhOtq7L66kRj5XlVRwS K8vfc/1dsOAEb1aQr5xgNMTJFl7x4u47T0TtZmeFWTZgUCumZjMaj831qz8sNUqw+sEe WaoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734884903; x=1735489703; 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=ctuXEQAvjhmDIIWoKLKBiMc6mMChQIOixW2dzl2+Gwk=; b=csxbfs+9qhu7Gv1j5SxDK656edjSo3PxMiQ/PoWkbPY+J/EFp1wnnb+71PVaTt3+zF CthWmUL0+r/ltWeSyit8JaRVFFQApGMj1s1iUkwawK+X/hUxH4eApl8w3Ti1XoZmzTae QA4Vk8kClqFHeKJCIxdDiY8AwkywwP204kX55Dj3VLns07vkF9R15R2SelTxlxxW2wt7 UIxpWhA6fInizwnIwxWu27QNjcAgnlsIBYWBw5mSluwDlWIYWoI6LTQKHHmp2+8JqJzl w78aKZDNVPJ1notR4ztWrZAPqy2FqGK6WdzVubufeb2MKSklkTLZqh8CQe717l+Or94e 4j/Q== X-Gm-Message-State: AOJu0YwQ/+vlNRkqd1xG0DgRcuLNmVf4EIHAqWIUTHH4QJNNVUXj5jT9 d97SemnhY+7O5SXcbOcJhmqiITECTGWdE12nbDVFbKAy3nzqv5ngQgVHvgfd4N6LN7CXkUUW4nU j7Gk= X-Gm-Gg: ASbGncvfDBgnv/OCsEkxtM1Z13rSpvz7DJPMatQtGEHP/dye6WH6Phkcajpccb/SQiB kAft3v/y+++dxUrun+DAuPholAYvG4lcWwl/E1XuhPVm23VYx5olBBdoCjkogX4Ic0uYZrr0UQ8 GoCPLs9ri5lMcC91W/8L5bMw0s68DLwbv09DUV4hzSP91NV4zribp1aRuFaDQ/UwK5TOFNbrmr5 m+UVi729Hr8zOpNFzoRbo+e+lY6VTCL9QrN8wrW/CG976aOlCMRtlb5N2ad0jI= X-Received: by 2002:a17:902:ebc8:b0:216:4b6f:dde5 with SMTP id d9443c01a7336-219da5e3ba5mr223023945ad.13.1734884902872; Sun, 22 Dec 2024 08:28:22 -0800 (PST) Received: from stoup.. ([71.212.144.252]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-842dcaca43bsm5848808a12.66.2024.12.22.08.28.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Dec 2024 08:28:22 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v3 50/51] tcg/optimize: Move fold_bitsel_vec into alphabetic sort Date: Sun, 22 Dec 2024 08:24:45 -0800 Message-ID: <20241222162446.2415717-51-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241222162446.2415717-1-richard.henderson@linaro.org> References: <20241222162446.2415717-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52c; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52c.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.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-bounces+patch=linaro.org@nongnu.org The big comment just above says functions should be sorted. Add forward declarations as needed. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 114 +++++++++++++++++++++++++------------------------ 1 file changed, 59 insertions(+), 55 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 607697e19c..312cbac690 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1179,6 +1179,10 @@ static bool fold_xx_to_x(OptContext *ctx, TCGOp *op) * 3) those that produce information about the result value. */ +static bool fold_or(OptContext *ctx, TCGOp *op); +static bool fold_orc(OptContext *ctx, TCGOp *op); +static bool fold_xor(OptContext *ctx, TCGOp *op); + static bool fold_add(OptContext *ctx, TCGOp *op) { if (fold_const2_commutative(ctx, op) || @@ -1341,6 +1345,61 @@ static bool fold_andc(OptContext *ctx, TCGOp *op) return fold_masks_zs(ctx, op, z_mask, s_mask); } +static bool fold_bitsel_vec(OptContext *ctx, TCGOp *op) +{ + /* If true and false values are the same, eliminate the cmp. */ + if (args_are_copies(op->args[2], op->args[3])) { + return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[2]); + } + + if (arg_is_const(op->args[2]) && arg_is_const(op->args[3])) { + uint64_t tv = arg_info(op->args[2])->val; + uint64_t fv = arg_info(op->args[3])->val; + + if (tv == -1 && fv == 0) { + return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[1]); + } + if (tv == 0 && fv == -1) { + if (TCG_TARGET_HAS_not_vec) { + op->opc = INDEX_op_not_vec; + return fold_not(ctx, op); + } else { + op->opc = INDEX_op_xor_vec; + op->args[2] = arg_new_constant(ctx, -1); + return fold_xor(ctx, op); + } + } + } + if (arg_is_const(op->args[2])) { + uint64_t tv = arg_info(op->args[2])->val; + if (tv == -1) { + op->opc = INDEX_op_or_vec; + op->args[2] = op->args[3]; + return fold_or(ctx, op); + } + if (tv == 0 && TCG_TARGET_HAS_andc_vec) { + op->opc = INDEX_op_andc_vec; + op->args[2] = op->args[1]; + op->args[1] = op->args[3]; + return fold_andc(ctx, op); + } + } + if (arg_is_const(op->args[3])) { + uint64_t fv = arg_info(op->args[3])->val; + if (fv == 0) { + op->opc = INDEX_op_and_vec; + return fold_and(ctx, op); + } + if (fv == -1 && TCG_TARGET_HAS_orc_vec) { + op->opc = INDEX_op_orc_vec; + op->args[2] = op->args[1]; + op->args[1] = op->args[3]; + return fold_orc(ctx, op); + } + } + return finish_folding(ctx, op); +} + static bool fold_brcond(OptContext *ctx, TCGOp *op) { int i = do_constant_folding_cond1(ctx, op, NO_DEST, &op->args[0], @@ -2755,61 +2814,6 @@ static bool fold_xor(OptContext *ctx, TCGOp *op) return fold_masks_zs(ctx, op, z_mask, s_mask); } -static bool fold_bitsel_vec(OptContext *ctx, TCGOp *op) -{ - /* If true and false values are the same, eliminate the cmp. */ - if (args_are_copies(op->args[2], op->args[3])) { - return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[2]); - } - - if (arg_is_const(op->args[2]) && arg_is_const(op->args[3])) { - uint64_t tv = arg_info(op->args[2])->val; - uint64_t fv = arg_info(op->args[3])->val; - - if (tv == -1 && fv == 0) { - return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[1]); - } - if (tv == 0 && fv == -1) { - if (TCG_TARGET_HAS_not_vec) { - op->opc = INDEX_op_not_vec; - return fold_not(ctx, op); - } else { - op->opc = INDEX_op_xor_vec; - op->args[2] = arg_new_constant(ctx, -1); - return fold_xor(ctx, op); - } - } - } - if (arg_is_const(op->args[2])) { - uint64_t tv = arg_info(op->args[2])->val; - if (tv == -1) { - op->opc = INDEX_op_or_vec; - op->args[2] = op->args[3]; - return fold_or(ctx, op); - } - if (tv == 0 && TCG_TARGET_HAS_andc_vec) { - op->opc = INDEX_op_andc_vec; - op->args[2] = op->args[1]; - op->args[1] = op->args[3]; - return fold_andc(ctx, op); - } - } - if (arg_is_const(op->args[3])) { - uint64_t fv = arg_info(op->args[3])->val; - if (fv == 0) { - op->opc = INDEX_op_and_vec; - return fold_and(ctx, op); - } - if (fv == -1 && TCG_TARGET_HAS_orc_vec) { - op->opc = INDEX_op_orc_vec; - op->args[2] = op->args[1]; - op->args[1] = op->args[3]; - return fold_orc(ctx, op); - } - } - return finish_folding(ctx, op); -} - /* Propagate constants and copies, fold constant expressions. */ void tcg_optimize(TCGContext *s) {