From patchwork Sun Sep 22 12:00:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 830119 Delivered-To: patch@linaro.org Received: by 2002:adf:ebcc:0:b0:367:895a:4699 with SMTP id v12csp1553266wrn; Sun, 22 Sep 2024 05:03:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWHVpdGrRfi1iP82nhn2jne0GlWo2cAabPapClEpdq+NEyswbfbHFiwRnPo8jCcVfPr87wv5Q==@linaro.org X-Google-Smtp-Source: AGHT+IEBimNZpN7wJb8ulfNR8/QCNyZhaUqZQSTTUZD+L13cPxtOohfn4/C+VvqRQFaau3PMPerP X-Received: by 2002:a05:6214:3c9a:b0:6c3:5bc3:78d1 with SMTP id 6a1803df08f44-6c7bc793573mr106613656d6.43.1727006593939; Sun, 22 Sep 2024 05:03:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727006593; cv=none; d=google.com; s=arc-20240605; b=YixDxGJaPVkZNdGx70VYEU5biDXyfQJW5XBAp2iXPEmEYiptrYvA/NOwbfMlUKv5rH xVvcdCRcV7d0VSTXApIttTASbTaPrb2BpsqD1bXXfa1gN3bddbxLkmEx/CHoZaI89rFh QMLNGMYts553DHgslmGjizR6lCHxwbwRep8iA8Nx8ZFickQxwpqGKQyYmg+VxqW6fX6r WLK/FXdTwkNyI2OnvbcZvQeNVYarASpRW7FiVHtZ0O/Xf2Kba5ODBGC8qIyar+YsGoeb EDaZ/XkSenxiF1fH+RKqSOA6Wz//G46pOGYemXsxhZZNRQyT03OTAoDWFFbpGSt29wiM MK5A== 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=OWl7Xv2JGXBckAdLaFuhNWtujP2/LH0xkeEqhVhx7Pk=; fh=tTjTfh/QwbpfIJ40uL4jnZOzWTJn3vAziy+Fmyen6KU=; b=dtrTMcc+wQJSTR30cRUpu2csieEFBKpQC+j+ktr0UNxk4ChD75Wx9BJQWMZdHkOwsX XwcCjTvrC3zDhDHoMsA3E+7tHmkF/Xc+QAUPbgo9MN9Q/IyUYDcK3huAWOeakBdBiMLK 3jzFgtRc9tySTxlXAXAEpIFA1Flau9WBnWUkBpWxJC9SEmWrGAvn772lPxDGROC0oQTx SAWulcdaQ8lyQp9cTumOnF5tF4etBDY45PVFnpR5moKXfakQm0kgJrfymAANQq3Mtx7f dqFVo/P8spiVk0SUJ/1JHmfWNc0JfwSEWVuJZswK+sHAwjKz5P/g5rmtDma4oQGd8DAn nGcg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sTy8MLsq; 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 6a1803df08f44-6c75e5a612bsi81902226d6.453.2024.09.22.05.03.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Sep 2024 05:03:13 -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=sTy8MLsq; 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 1ssLI3-0002ur-QJ; Sun, 22 Sep 2024 08:02:13 -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 1ssLHJ-0000vj-Hb for qemu-devel@nongnu.org; Sun, 22 Sep 2024 08:01:33 -0400 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ssLHG-0002NR-I5 for qemu-devel@nongnu.org; Sun, 22 Sep 2024 08:01:24 -0400 Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-a8d6ac24a3bso586408666b.1 for ; Sun, 22 Sep 2024 05:01:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727006480; x=1727611280; 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=OWl7Xv2JGXBckAdLaFuhNWtujP2/LH0xkeEqhVhx7Pk=; b=sTy8MLsqi0mWU5nbTQbtd5JfE418QSyKnvLNr3b3wQzk0M/n8tOSRa5K6OhBgxiseq iJQIdObHMCm9AK7DSTsQ/r9Me+CmqZJMi8aCrC0e4TgJ3Is/sFYszjHCnpUvGbKMOiy0 BxuMSp0AaIHJTL93Mo176Wk2xRXjhG/L1O96Ikry/IED762pMQVQY0n9fbgHKJ9c59NX n4cZ/ySfzgc283dNY9myO+iE8mwnEwYP3j//XDbtP7u1jB/sDHN/+6v/HT9MiA2mBU26 dhH02zthkc7L1W7pllgiTHFx/xlwuZVjYdq0DjCZNf7kVbj2dFCFGeRVTdixlgtPOOhI R35g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727006480; x=1727611280; 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=OWl7Xv2JGXBckAdLaFuhNWtujP2/LH0xkeEqhVhx7Pk=; b=RdiiC+uIpwyROzHIbwTcGm9Zlr0Z0+dKbWnbJJWDXuVZSpPHbZ22zWm1ASjURC5pWH NnbkMFTiJC6RcCjulHuBBUP3tyTEu/d39/ZFvSAuGvKFBdkz1S/LC4GVyxqlATkCA02A KusX62o18zG9LQDKju58cWh1UlbKe4RNf6SB1KDnnxKvKO9miNKSyBbnSrQJwsOeIqvv 5VDE+e4BvMTbqD/At20TQbn7cvC3QwcyY645PS2r6o+2jbDSI9rFtynmC7zcTuQ/0F1l 5DaXbaL2lHrq+SMNkstixTSaGF1GSoZKk6SCJwlLDR0SWLlQgLqK7ZHnyf51Da2LXgV3 2AFg== X-Gm-Message-State: AOJu0YxC8K24qYYIGSEGpOdDJdYebrxHIvIyuT5EujuIl+bqVPCFEEfI nWbF5JjfkPv18F45+/ISV2NlA1WuWMULWQx/LZfJNHu8t4wgnpUnYlBMnaFHLsoYypgIUqKI1G8 xDqU= X-Received: by 2002:a17:907:9482:b0:a8a:85c7:8755 with SMTP id a640c23a62f3a-a90c1c747a4mr1385383466b.11.1727006479667; Sun, 22 Sep 2024 05:01:19 -0700 (PDT) Received: from stoup.. (90-181-218-29.rco.o2.cz. [90.181.218.29]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90612df525sm1067909966b.159.2024.09.22.05.01.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Sep 2024 05:01:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 10/31] tcg/optimize: Fold movcond with true and false values identical Date: Sun, 22 Sep 2024 14:00:51 +0200 Message-ID: <20240922120112.5067-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240922120112.5067-1-richard.henderson@linaro.org> References: <20240922120112.5067-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-ej1-x631.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 Fold "x = cond ? y : y" to "x = y". Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/optimize.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tcg/optimize.c b/tcg/optimize.c index ba16ec27e2..cf311790e0 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1851,6 +1851,11 @@ static bool fold_movcond(OptContext *ctx, TCGOp *op) { int i; + /* If true and false values are the same, eliminate the cmp. */ + if (args_are_copies(op->args[3], op->args[4])) { + return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[3]); + } + /* * Canonicalize the "false" input reg to match the destination reg so * that the tcg backend can implement a "move if true" operation.