From patchwork Fri Dec 20 04:11:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 852379 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp1853168wrq; Thu, 19 Dec 2024 20:17:27 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXtuRSoDjXfFpqbSXy7Ya05b7sGuIWy5Bcwus0oWQ/Lr36+FP5qKURlAfJnFdZickkRjpY/kQ==@linaro.org X-Google-Smtp-Source: AGHT+IHz3exDVB9rys7jl7AJja2TaowGVFh7frz5W0QtE8DhCXUWrhWUUdG8Sm8laQjaSME+rwLv X-Received: by 2002:a05:622a:5c6:b0:467:68a3:4c44 with SMTP id d75a77b69052e-46a4a972791mr30248071cf.39.1734668247313; Thu, 19 Dec 2024 20:17:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734668247; cv=none; d=google.com; s=arc-20240605; b=gHg99IlcL8cLTiYBUeDGa9vHNRH3ymphyGlL0kIifsxJxc/Imufa4BSHiPop5m0jhl DQ/K48PldjwbMRKPV1+0LyIWW3CPSN5dXOi80aTDSX5TmT0Wx98oYDsnYuHf+fgrUqTD q9tCbh9ZEyOTIkFhvwmurcCQGxlbzhAF84lg99F1TVJ+g2Zz7lIgTnHXEgIVNMLryj5G q/75FGZCPqMGqUzk34Wh6SZ6Qb+DaQfNqlcoJxPd+g3EoTEwf4UysbGRHkdvjZQSPFYL cW/MupvILdgnQCF1OUJMqVfUwgwvdtvxBLGICDp4HVmXQZxpNMQ6U7rA/t+JxRqEzbno xYMQ== 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=KAulOf64Aq+MQyz7Gm3afpYDj7PG4HhSWEO5QGhMKrY=; fh=vm85eyWrvOAHduw3sqEA+cYBqvHB7M0MHFcRJg7VWOo=; b=BqZ9FWIOZ5uZqeEEvO82i7+n9dQ3oFD0ibYoKO/fHzJdb1lFArT1uLWhkPFMRBFUZf V+Q1Fzf61C47CnNPjqCm0f/nOIh0+Thza9+oBFQX6x+fqFy3Q50hID1vEaQ92P39Cbbg murtna6K0Nhc2QOgMrfqjCNPP3TIsKC7f+MAwoVd9o7NZm5tmbnVl0s2jX8cB43Y4BB5 KHIfyo1+HzN1IaxaWNJJpc4HiL6FtaX1eF9hYkv83sH+2dh0Jfv0eXk6SrMKzgdKK7PY rxHq1SSd2aYv1xmwWynSfCe+w3EIYnQVPg9oJ1QHmgDjR+JSb8fg+n0OrAHzX3hJn769 U3HA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Gl2dV9IP; 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-46a3eb9914fsi33616881cf.340.2024.12.19.20.17.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Dec 2024 20:17:27 -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=Gl2dV9IP; 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 1tOUQv-0003TD-BI; Thu, 19 Dec 2024 23:16:13 -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 1tOUPW-0001YW-Pj for qemu-devel@nongnu.org; Thu, 19 Dec 2024 23:14:50 -0500 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tOUPU-0006rQ-Vi for qemu-devel@nongnu.org; Thu, 19 Dec 2024 23:14:46 -0500 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-725abf74334so1298126b3a.3 for ; Thu, 19 Dec 2024 20:14:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734668083; x=1735272883; 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=KAulOf64Aq+MQyz7Gm3afpYDj7PG4HhSWEO5QGhMKrY=; b=Gl2dV9IP0oXdOC0s8bsj0MfbbJbthae2MNj2nYhJXXnKFQsTi5WaajgQsmdlXZc/is gilPTa5oIUItv5AXMe9JoykD9e2i8PZNpc7HIuFswCmTXtlHs6wvd12Tb9iwN/m9bCpJ iNE0RJVYkDJJBAsBKSSyyGD8sTeVSYf9+yAtAcycXxZQhAWfxLlKi7B7y66e85XVUs4N o4X6Sd6SLeggzy32IOGAPUcLq1vMv+PLESgW4GzjcWaPoR+b3WZRKW01d12iWrNTflTJ DiPyIXxlqju8PhTIRY4Zr12zJLMzUCXeSwTEoU/9DfLNlBj6ndu321s23NV4JT3Jn3np Hf9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734668083; x=1735272883; 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=KAulOf64Aq+MQyz7Gm3afpYDj7PG4HhSWEO5QGhMKrY=; b=QuG8dzmAKn+TekqY5eB0DuCYr5dYNeblFHp/YsZWO7xi2BBNjiUOAJqfu73znhXuMX 3zXmwhfRHP/qpif8eIJzP0StG50YK2a2Hr3R17FajYogOwwd+Wl2vCCaQAAfqSDOaGFK qH/s1/7RgSZkHIY2J0IVolCZyNh1iqfpe65c8v7jSCD7DVwcSrJuWKeLyORXgCHrjymu ESrl4dmrnNp57iNeRKev8C6vopf8M+NVDTMXgkQSO6zQ8eKMBz8eB171bBj9QY1Md0bS MJ86KbrXOoocKvwH5C6RHbcZj0hYepienURpl7rrwc+KPEfT24tNObwMu1GeVX/nDp+X l5vg== X-Gm-Message-State: AOJu0YwVyjnatjpNNVvTyulhmjleCYKpio3oD6PWuKsT5kDEydGUk19R Z2kQUgyGPJWf1uyZiBlUq8paCksCbTtOzJLOwp2OJappo4uG41jtyW25NdN/EENIEAkR8L2YK+E G X-Gm-Gg: ASbGnculgmr35MLufq32TAS/VpATL/Y+jZrIPmZSTwWkXGD/ACJ2F1pvBJTi+I7yxfR 7FPWAsdlCj882m/Cbtc4nuyV2B4lY+tqqjV5KlZHihDsw/EZn6KPyttZuYH/0feb9Ck/tWxTC6P 8KWDznsqaoe8ZO9PmgkezAvO/6QR74GFh3rx2MgbyVMq3luGZl1dTZPpkAuaNXUN8/zdnU3B1H1 cMuas97NeZuDDlCIWnFkGR6wpBt50To7p+Ke8c/K/eMYZkUWoSmwwkYlmTt5rA= X-Received: by 2002:a05:6a20:158c:b0:1e1:afd3:bbfc with SMTP id adf61e73a8af0-1e5e0446374mr2820327637.3.1734668083253; Thu, 19 Dec 2024 20:14:43 -0800 (PST) Received: from stoup.. ([71.212.144.252]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-8529e78a55dsm506952a12.80.2024.12.19.20.14.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 20:14:42 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v2 50/51] tcg/optimize: Move fold_bitsel_vec into alphabetic sort Date: Thu, 19 Dec 2024 20:11:02 -0800 Message-ID: <20241220041104.53105-51-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220041104.53105-1-richard.henderson@linaro.org> References: <20241220041104.53105-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x429.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 2b64b8a0ec..4ec70130a9 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1211,6 +1211,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) || @@ -1373,6 +1377,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], @@ -2799,61 +2858,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) {