From nobody Wed Nov 27 11:51:45 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=1699325417; cv=none; d=zohomail.com; s=zohoarc; b=KiXHOeXca13fXMDDksFjHWyhXEsA/rIAoTdNoeo/MCMHbThNJHxPiFYDWex1DaCHzVhjAZpKSXWGS8BBIBUNzm6sjbHpv61x4ZO+/WaiVnckS3Jr/2EGuQkZwr8Fm8KCgOO4DxLvFaR1uv9PSI2b+3OpAeao92cRaE7d6J5dQck= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699325417; h=Content-Type: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=YHmBTBkZIpyIbEJIll5966friKsejaD+iHlMP+LfScE=; b=VMTwriPq8p9LV3S3WZZTULI2gyrFfjs2AMnaws1TZhAzVdbbYjjDY5LbEK6F887Gt2SienNy1kd3c7Gikh5gcNQZAacNLhhyahMC1nF77KjoJCwiqDecskg1stH4hRBPCp9xgbTmV3Nt66f/3eEifbv5kbwQvji5iKHMu1R1Q+A= 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 1699325417601522.0376820692967; Mon, 6 Nov 2023 18:50:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0C9T-0008SW-HH; Mon, 06 Nov 2023 21:49:15 -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 1r0C9Q-0008Qx-Vw for qemu-devel@nongnu.org; Mon, 06 Nov 2023 21:49:13 -0500 Received: from mail-vk1-xa2c.google.com ([2607:f8b0:4864:20::a2c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r0C9P-0005wh-IG for qemu-devel@nongnu.org; Mon, 06 Nov 2023 21:49:12 -0500 Received: by mail-vk1-xa2c.google.com with SMTP id 71dfb90a1353d-4ac023c8f82so1566268e0c.1 for ; Mon, 06 Nov 2023 18:49:11 -0800 (PST) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id fn11-20020a056a002fcb00b006bff7c36fb3sm6367478pfb.95.2023.11.06.18.49.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 18:49:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699325350; x=1699930150; 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=YHmBTBkZIpyIbEJIll5966friKsejaD+iHlMP+LfScE=; b=ieVjWNmem8Ga4QJGRrNvnMPgxwmaktNVS53aDo0vuUmfd2O8D1XJie9BEmWGVQTdGh AA+TFxXAgZOJZMfs1pj80cXFvXQU/OZITGQWozmctyr+BVYZtha/rjdorcYK5UmQZ+r3 gsXby9CoQ8rWGQnnouINm4+q8eiPpRf0S3847y9LfZJmfJEYeaZ/+JUKpa//TlrM0yxI vD3xrv6fTUiXZ7TzsK8bnkcQvKQS/4KgYn1CkfEOAgWWUFTdqcRyWh8TBmfl1PDf2EWT zTyXUd3gRu9NG5e+JwKKj+p6OgD1QpXy9AEM+r+/Wf4td2v87kS2RNC/dEIVn5F637Ln Medg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699325350; x=1699930150; 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=YHmBTBkZIpyIbEJIll5966friKsejaD+iHlMP+LfScE=; b=tS0VvFtA7nI7pAlnerAtw1t9GNAExHvkV+jgt6eS80WD2BiS3YgwkQwLfMhlmG+IQF /hcOAtRYBqU994xqiz0BtR6ZEJXKNkqUwoRXIStAMFMeSss1uS2SkEpk1KnXQc/ytWsU wmgb4sUrv6u/OEof/jePegeVTO/VTremz12QRsmIGEDcGrSahbBXatNSVKlWWVkcoqs6 KhAc3i+4ZCZfVlJcc+EcTTdsJyPS7e2UZ/QHE5YoYIzyrXA3nCzwea6I13lCGX/muY6/ BiDcxiDCOh1b4+a2ga69RZnZhfaot1xVWUdksud6dOj01AarMXHB75lDOXE0VNnPVzFQ 3Uzw== X-Gm-Message-State: AOJu0YyNtWEcEnUjPieTFrQliMke6cJaU/rjsDxnOnPInrah7AgwbjOj Rqac7bnLZ7Q3ECHlwT6zVvacyuOcnSEq+6JDqPo= X-Google-Smtp-Source: AGHT+IGPbnjkCGS6WC4muG38Cnw3Lrn2mJH7W4vij9s+fg57aOT0UW0Sj8NLxbTNvvB6lg42FzhZJQ== X-Received: by 2002:a1f:2992:0:b0:4ab:fbff:a811 with SMTP id p140-20020a1f2992000000b004abfbffa811mr6793222vkp.14.1699325350551; Mon, 06 Nov 2023 18:49:10 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 33/35] tcg/optimize: Canonicalize subi to addi during optimization Date: Mon, 6 Nov 2023 18:48:40 -0800 Message-Id: <20231107024842.7650-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231107024842.7650-1-richard.henderson@linaro.org> References: <20231107024842.7650-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::a2c; envelope-from=richard.henderson@linaro.org; helo=mail-vk1-xa2c.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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1699325418253100001 Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20231026013945.1152174-3-richard.henderson@linaro.org> --- tcg/optimize.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index d8e437c826..468f827399 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -2166,7 +2166,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