From patchwork Sun Sep 8 02:26:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 826449 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp1425217wrb; Sat, 7 Sep 2024 19:29:06 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXCT8bPxLuxX1LpbyzOerZov4NqWJ2GLYkT0qTKFi+Me+lKH82uVpVEFlRF90goblnR3+VYxw==@linaro.org X-Google-Smtp-Source: AGHT+IF7X7qq/3BLZ5owofAsHqaE7tDL5VRQxmWQ1UJTDl6i66q4kZTEp6lvEky8JPxytZSgaQb5 X-Received: by 2002:a05:6214:3b82:b0:6c3:5db2:d994 with SMTP id 6a1803df08f44-6c5284f63f3mr71967016d6.5.1725762546039; Sat, 07 Sep 2024 19:29:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725762546; cv=none; d=google.com; s=arc-20240605; b=W++TY3nDnrydisTlO3rVKWACWAHjllHlJjVv1x4JGyOmq9bZWT4vwgw1PAWQW2Cq9o nIpBw985zAXJzF7Eh4CDptVPxYTNLBR+jKA5d1n8prvz+OKyymzmQ+YPjsHQi6D5rVAn 2BE4SLXJ2CtaCc1hLNZ9yAQJ/6ALxXAB+8v9lAl6lfgBN9jRQkSChS2L8gGYv8NTV8ep GEHMrzgwjanlFGA5vpGaCp6aYl1QX8/TUOxG7ReoWrRpkxNHrtYWeeLjd7ukX9BW3GsC RhEVF0CJEX/Fw8ehQdnXtIROtHKzN42t3nRHH/NRw5u2LgOn19dT3Fc7ld8TVA05rz1y 8PFw== 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=/GYQH+qlsiZNusd91SlPcZXeCA8M1xc1mlbTAMFEsWI=; fh=ygZYpEcIWhzezS2Faber1kIRniTU78jI+DFuNO+oyiU=; b=Bp77CZL1QwcUQpzfrqKjr6RNITWdoDjKNCK/Zp9YdkERSEpEwYArbXL8gsbvI8RbwA rAbE92aLwcS2Ai/q4qEathZNdtXuPVKPWplx7IrZxIsmNQUDGxlpg4kVHzGMdujYWLQf TNiyYA/5VxmK4Q3ikeNmrUeMRM8g89QDtG1etQPl082LNT49XysFOluwrz9hnhP0Y2nM ggrXSfcqsm5VrfQoyVP8gbsjNZ4LSRTxOKXBkC/fyaVuWI4mOOawY3u3wF7T5061uivu l5LyQMZJQQIZz5lLCE/52BzplAv/qdZ1eTH308KIo0NgvxXWDbb4VfoclEF4KUCSLA8w g5fQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Gb+ABANn; 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-6c5348ca10fsi24766596d6.581.2024.09.07.19.29.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Sep 2024 19:29:06 -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=Gb+ABANn; 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 1sn7dW-0003Mj-5f; Sat, 07 Sep 2024 22:26:46 -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 1sn7dT-0003AQ-FY for qemu-devel@nongnu.org; Sat, 07 Sep 2024 22:26:43 -0400 Received: from mail-ot1-x336.google.com ([2607:f8b0:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sn7dR-00050n-TS for qemu-devel@nongnu.org; Sat, 07 Sep 2024 22:26:43 -0400 Received: by mail-ot1-x336.google.com with SMTP id 46e09a7af769-710da8668b3so479554a34.1 for ; Sat, 07 Sep 2024 19:26:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725762401; x=1726367201; 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=/GYQH+qlsiZNusd91SlPcZXeCA8M1xc1mlbTAMFEsWI=; b=Gb+ABANnyglRwCEUKdp1iR5BZKFJJW40P6+kTmoyAG4mpkNY6+6cThqutRiZ/ar1dt c7ILOiTyiUHdBPjOY9GS8rcyrnZoYaX3zTYcduwpecjnTJ0pLVQUEgtizLU8tl2CqXk9 hTQjUtBx3r84tLvXHhf5L0z/iGVk3kOL6Lgn6LqI9KL8ZQOpn5y0lUNNwD8os0duUi+c H+DPXVANrc/gjZ94gCcJgq9GRjS6xR1R2Z7LTajmPIRle4M5iI1xrYOj3x+SU2IOe+yO vKv+jIv27V4f2agrnnlHaXNs2lETLsSTZ7JxxbQQAFksfb0TSkTzCd/KnfIPw5WfGHf3 93hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725762401; x=1726367201; 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=/GYQH+qlsiZNusd91SlPcZXeCA8M1xc1mlbTAMFEsWI=; b=O7FaezAotExGCDzvUbJCgqMwk45Cijrq7HvmRLiGj/cNFxQumDcEl8blqpAiqnLEeF 51bvnlDt6urH22qTxAQSrRh7fJGohRoRMctnhK62LHhasUXZJ5Wm0JcKpwkl3Gyy39f5 ROF8Zbx2Y3efL5sv6Lq9ArGBZTPoTiwhib2RumiG6c76b8ZY85ut1PkKRBPcoEkCOUbE 19BE+RSz7Gf6SCL+mDhBJz/ufMIRcXTeQ0PTd8/hy2G9f0luxVNG6CLYNfTXZlKBCQCU WFy9ipnoiFmCrwARzWE8MIxtXARsi6X7YpDgE0LDpGdxEMS6D/dao1enEsR07k5NNt8B kHAw== X-Gm-Message-State: AOJu0YwvhIYtM0VfHJWBevTfbbSEfLThE6eC/RI29EEaB+hOP/AGEEWJ WC6IRLFLwV/E6p9PXoIR04weVpLRoxhGjMStxVMp11E1+wm3HxGAhRxFdJkYwCMVHDfL9EyUORi Y X-Received: by 2002:a05:6830:4411:b0:708:d860:e51b with SMTP id 46e09a7af769-710cc22c384mr8034581a34.15.1725762400534; Sat, 07 Sep 2024 19:26:40 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2dadbfe46d4sm4084019a91.1.2024.09.07.19.26.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Sep 2024 19:26:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: zhiwei_liu@linux.alibaba.com, tangtiancheng.ttc@alibaba-inc.com, liwei1518@gmail.com, bmeng.cn@gmail.com Subject: [PATCH 06/12] tcg/optimize: Fold movcond with true and false values identical Date: Sat, 7 Sep 2024 19:26:26 -0700 Message-ID: <20240908022632.459477-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240908022632.459477-1-richard.henderson@linaro.org> References: <20240908022632.459477-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::336; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x336.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". Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- 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.