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: 60495 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9296B389EC4E for ; Sat, 12 Nov 2022 21:31:13 +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-Google-Smtp-Source: AA0mqf5c8z6I709oNN/yV7r51WNpAJy7+EW0NdRVgNDtAygn7QuoP9Fwm9DhuaDpj1oGY597qE30og== 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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)))])