From nobody Wed Nov 27 15:48:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698284428; cv=none; d=zohomail.com; s=zohoarc; b=QQSDC2l1n5jrNdfv2NyWsQ6IXvnBF2hOaZTX3f38t7qa1/CdnQmSakvPY3EbtEVWgsBaX8wHDbW58YNBaXdSDKCb0XZaichlqsoxx/K/2qC385pQi+bzP2xfp2w0/+5BiFpLvJzKWQbIIF6R+WGb4GEVV4oiXXUevJM9J2k+634= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698284428; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IT+iq26XpeNaP4p8agkQswthWt+k2V7nM8eUPcDBar8=; b=GvZLS+uuNdHvt/RDA9awPP9GG2Ongje2koJA8IpWbQGlQKo92iPSHRscILf8NQbTp04y7rK2s/zvGSbpXXOM4IL1cOidD23DHkwe0ccYlEuBjmln/Rr7LgGIDXQjXOsi+wpueL7j2MfbWRGZa3pCaZFg1JfLD077DIx6hyWI+Cc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698284427918432.232539343069; Wed, 25 Oct 2023 18:40:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qvpLk-0001sl-Og; Wed, 25 Oct 2023 21:39:52 -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 1qvpLj-0001rh-Ef for qemu-devel@nongnu.org; Wed, 25 Oct 2023 21:39:51 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qvpLh-000348-Le for qemu-devel@nongnu.org; Wed, 25 Oct 2023 21:39:51 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1ca215cc713so2413345ad.3 for ; Wed, 25 Oct 2023 18:39:49 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id y6-20020a170902864600b001c0c86a5415sm9817032plt.154.2023.10.25.18.39.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 18:39:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698284388; x=1698889188; 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=IT+iq26XpeNaP4p8agkQswthWt+k2V7nM8eUPcDBar8=; b=l/3NxxcXjr8ZuVdTRjiRuhrNC5nDjcOePV2+lHRYqLNFSWzhRgKJboNbMwv2os4Eff UM/X2JPeFsvCJs+k8XUQ4tk/UoMm7Q0S35dVvtUarHDPxSux4riuwgOO5owAmC1OMe2h ewMiZ+ai1tTSkpOgqCrWytQehS61vfZZAl3iIYnJVtEQIBsJA0pBb5ZPZdZqkJV8MNnQ hmEhUB9scSRggJB1rXsWF2mTjuNFiiwYj6It7FSXkxvgI0Qn+P9dm0sNkgOwYweZrc4J 7DMshuHW+gGEuFpVcd0rIgV1ZM2grGYYWD/QFoz8C6YxKuB3ij0eeB9q3OnkWkEZZd7E cnoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698284388; x=1698889188; 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=IT+iq26XpeNaP4p8agkQswthWt+k2V7nM8eUPcDBar8=; b=cu5mzUJu+jqVD/NyXJFvtgpXJ9Yl+vcE4/fLSwyZiKj0+PoTVqEl51VCFsRMyorbCg keszT//nMFb8v8kcZX3pNLT1cXu6poL8dyRn7Am7AKSWqaUI2ZW7qYmOVgPCNE/iDCee F2JNU88o6aLXPNko0sUVmOEUxLmnN6ZeZxnm0xpjiwWetS5K5lV2IbuyzM+TnIRMO/cv QbObqUMeOGtRihQz7kkdxzFH9rtPIlKqLTkPjU97LPr04pKHE7m2cZUfQe+L+reBRO+C q3az8GXCeEiSvR9rFnYg/AMrTgTWgJEtYETaKhn6PAIZnPYgAYt8o4xkxcEJUX+KzD7h Bjig== X-Gm-Message-State: AOJu0YyV4QFRXam3fkiW6TmuwtMMJi2t+yrxU1g7n8/hpoIj6jYZlFeD inEgorpmgf08f9qIE6XYeUsf6x7uoeaZqUdEwKg= X-Google-Smtp-Source: AGHT+IFrBiVu+C4fT/Ae5/5DoekgxxQH40tSnTfO4tDle+zTU/ct/ZoKKSQvSKTNhDoRATapmEhk5Q== X-Received: by 2002:a17:902:ca14:b0:1ca:8629:829b with SMTP id w20-20020a170902ca1400b001ca8629829bmr12274464pld.50.1698284388020; Wed, 25 Oct 2023 18:39:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com Subject: [PATCH 2/4] tcg/optimize: Canonicalize subi to addi during optimization Date: Wed, 25 Oct 2023 18:39:43 -0700 Message-Id: <20231026013945.1152174-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026013945.1152174-1-richard.henderson@linaro.org> References: <20231026013945.1152174-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698284429171100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tcg/optimize.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 5e16800cfa..9d91c25f68 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -2237,7 +2237,19 @@ static bool fold_sub_vec(OptContext *ctx, TCGOp *op) =20 static bool fold_sub(OptContext *ctx, TCGOp *op) { - return fold_const2(ctx, op) || fold_sub_vec(ctx, op); + if (fold_const2(ctx, op) || fold_sub_vec(ctx, op)) { + return true; + } + + /* Fold sub r,x,i to add r,x,-i */ + if (arg_is_const(op->args[2])) { + uint64_t val =3D arg_info(op->args[2])->val; + + op->opc =3D (ctx->type =3D=3D TCG_TYPE_I32 + ? INDEX_op_add_i32 : INDEX_op_add_i64); + op->args[2] =3D arg_new_constant(ctx, -val); + } + return false; } =20 static bool fold_sub2(OptContext *ctx, TCGOp *op) --=20 2.34.1