From patchwork Sat Nov 12 21:29:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Tomsich X-Patchwork-Id: 19263 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1435186wru; Sat, 12 Nov 2022 13:33:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf6US07dS0R7hrBkWSJB/7BEmHYz0fWRxdyTBBjqRXgDCTYDAgW2swjHnHQL2FCT3sIQLlQQ X-Received: by 2002:a17:906:28da:b0:78d:95d8:f8db with SMTP id p26-20020a17090628da00b0078d95d8f8dbmr5753672ejd.592.1668288829625; Sat, 12 Nov 2022 13:33:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668288829; cv=none; d=google.com; s=arc-20160816; b=lPijjE6FEKiN5mwEZvj2/j8whwlZddEo9vWAmEgd7/a8lO0lO8La4dg3bGwtEvPzVI bi6aepURkwOVF4+pW9EAXDz5IYMSVw/Vc33swR88q9xlyuFYKrfnHwjyuIagqXr01QEW V3FEMCTUxNHYZY6kZXj5AuXgMhHktnAxA3StUNNAtEAL4TeAzc7V+Vkk8mohm0xBgke2 zFN7yNTFDUU6jUJgBWroSo7aCQqu7HIxI+x0J5t4HoGVaVCgohG41bZrZcmNJQtU5/nw 3C2El0klaQ3xeBOonflpWRmOXtI2oTxdweLTcG+JDzEZOc5E4ScGZpsp2AyURkBLU+Dr hXGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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:dmarc-filter:delivered-to; bh=HzM1g8L3yNLOBnPg7N/FUArqD+BUKb9iG4pB+KZCidU=; b=aggeKbchwCbkEUn1XZrSE+K91w5nd5nJaYd4gn6bQ7pm02t76XsQm51Is5VunhmZAm dmZnRcbJTXC9e4WzZqJaUVru05giLzZnGgrOK/aL61PN640KCK4ADaclKMAM72Lgv+Zw gLzW5DIomhh8h0NfkfVzB+13+ETiXSo2pvx8z6T00FGg0R/c1B/6IrQx/VsCO0JImB5+ d/qtxIfuT3bRrB9Xa6maACgNPCa91K9Gd6OMSWSN1O92Q8U45urV268W2W3+84juphBe 9ZkvYFb74obPxdYugnG8xG2x3NIQLB8e4UY2oCOZg8f6znaSy7yE4r5WAHJyIxMo0ZO+ 6vPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@vrull.eu header.s=google header.b=MTkwBQqm; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id gs6-20020a1709072d0600b007919f213511si6178773ejc.951.2022.11.12.13.33.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Nov 2022 13:33:49 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@vrull.eu header.s=google header.b=MTkwBQqm; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6D65A38A8177 for ; Sat, 12 Nov 2022 21:31:21 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by sourceware.org (Postfix) with ESMTPS id 948DF384F032 for ; Sat, 12 Nov 2022 21:29:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 948DF384F032 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=vrull.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=vrull.eu Received: by mail-lf1-x12f.google.com with SMTP id j16so13349733lfe.12 for ; Sat, 12 Nov 2022 13:29:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; 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=HzM1g8L3yNLOBnPg7N/FUArqD+BUKb9iG4pB+KZCidU=; b=MTkwBQqmIOw72HkCRaUf70GCoXEjrKF49kHUSuJiRHqhm1l50Fv5pgVmBe1uAh23AW PK5N+YcExSLWHnkIvcxYUP+xI/GJVUqpx/Nf/SvfTl/rh18R52Sh/YyKrjlewEUA3Dao IqA7rjv0qVPFeI5dIulaNWtgsZC6vWdHs/ljFraJXD1rAc1R3B+wY+F7wwvDv/ZZvDMp VUQlOP6ergksB7KydjPnRKwnL52BFqo/5uv3zDpzi1E5Limd5nn+6bveqatwFgWFugE9 Cv34IGl2PTs5H0CsN/+eudPZi+i9IJN3B0ZuDUnwBYechWKwF95ddZ6ge59x330m17F4 sQ7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=HzM1g8L3yNLOBnPg7N/FUArqD+BUKb9iG4pB+KZCidU=; b=QRErHL1AMzZK8UMm2WDYmv5mFSyW9oM3UQGYwj0cnmaGiJwq4+qx9zdOBhz+BxFDXp V6SHBij+v/z8eGO6tYFdY+NuPcndeKJl+viUAbLHF0CmRkc/b9WIBuVtEv+dT953N5Cl oCuAqspIyZdWbWCwHCqKUSy8BQ2+ZNKvLnhQMYfwoOLCK9eMtppb817BkjHv4uAL8rU/ 2W2ZEsapFnwb6vhnRNMSGXRGYAahuHWouVVKP0WA3XQ4f0C04bifJn21/JWTuCfbCNrD kKhijXudC6oaH9MUb4rZuiN+HpZzpfOJBFzhgiDYPNl3IYY7XQKq/Y7qAh67Vh54SN/2 488Q== X-Gm-Message-State: ANoB5pnidiFmeHrYWmXlFm9VATC5svhv4kG3Bwro7XMj9HdYU276IoyF pP8k6D/zEhg5a2Goo3IJ9UeDnRDqI3QjVZu0 X-Received: by 2002:ac2:4daf:0:b0:4b4:661a:1ce1 with SMTP id h15-20020ac24daf000000b004b4661a1ce1mr2694946lfe.136.1668288593810; Sat, 12 Nov 2022 13:29:53 -0800 (PST) Received: from ubuntu-focal.. ([2a01:4f9:3a:1e26::2]) by smtp.gmail.com with ESMTPSA id b9-20020a0565120b8900b004a4251c7f75sm1042967lfv.202.2022.11.12.13.29.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Nov 2022 13:29:53 -0800 (PST) From: Philipp Tomsich To: gcc-patches@gcc.gnu.org Cc: Vineet Gupta , Palmer Dabbelt , Christoph Muellner , Kito Cheng , Jeff Law , Philipp Tomsich Subject: [PATCH 5/7] RISC-V: Recognize bexti in negated if-conversion Date: Sat, 12 Nov 2022 22:29:41 +0100 Message-Id: <20221112212943.3068249-6-philipp.tomsich@vrull.eu> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221112212943.3068249-1-philipp.tomsich@vrull.eu> References: <20221112212943.3068249-1-philipp.tomsich@vrull.eu> MIME-Version: 1.0 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749327628069362995?= X-GMAIL-MSGID: =?utf-8?q?1749327628069362995?= While the positive case "if ((bits >> SHAMT) & 1)" for SHAMT 0..10 can trigger conversion into efficient branchless sequences - with Zbs (bexti + neg + and) - with XVentanaCondOps (andi + vt.maskc) the inverted/negated case results in andi a5,a0,1024 seqz a5,a5 neg a5,a5 and a5,a5,a1 due to how the sequence presents to the combine pass. This adds an additional splitter to reassociate the polarity reversed case into bexti + addi, if Zbs is present. Signed-off-by: Philipp Tomsich gcc/ChangeLog: * config/riscv/xventanacondops.md: Add split to reassociate "andi + seqz + neg" into "bexti + addi". --- gcc/config/riscv/xventanacondops.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gcc/config/riscv/xventanacondops.md b/gcc/config/riscv/xventanacondops.md index 3e9d5833a4b..22b4b7d103a 100644 --- a/gcc/config/riscv/xventanacondops.md +++ b/gcc/config/riscv/xventanacondops.md @@ -119,3 +119,12 @@ operands[2] = GEN_INT(1 << UINTVAL(operands[2])); }) +(define_split + [(set (match_operand:X 0 "register_operand") + (neg:X (eq:X (zero_extract:X (match_operand:X 1 "register_operand") + (const_int 1) + (match_operand 2 "immediate_operand")) + (const_int 0))))] + "!TARGET_XVENTANACONDOPS && TARGET_ZBS" + [(set (match_dup 0) (zero_extract:X (match_dup 1) (const_int 1) (match_dup 2))) + (set (match_dup 0) (plus:X (match_dup 0) (const_int -1)))])