From patchwork Fri Feb 10 22:41:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Tomsich X-Patchwork-Id: 64726 X-Patchwork-Delegate: jlaw@ventanamicro.com 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 78B1B38845F9 for ; Fri, 10 Feb 2023 22:43:25 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by sourceware.org (Postfix) with ESMTPS id 639A0383FB93 for ; Fri, 10 Feb 2023 22:42:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 639A0383FB93 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-ej1-x634.google.com with SMTP id lu11so19518664ejb.3 for ; Fri, 10 Feb 2023 14:42:02 -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=+mVEWzBYbxNsPTC4LhYIO4HlW1rrZO7Aog0YjWTPMts=; b=ROirhVAIz8uqA84Qt95R2421SNkVmw34wUpW0WUlbOoTcFuDx4KXHXTJDlF9lhO4Hx QoHNfhS0SHfL9KS3p4HywlkbDh/KGCLYBs+LmDDsRZWUHhzF04bBG77NujUIXDdtHIIN zHXChfbSXU1jHpe1v6mJDu2ub1NgiPD6yM/5XuM8lSTS59q11i8RLLeqsxWRa8VBVU2M NwnUNu0eIs5LTL/pMK9W8q9ZUDXCNU0QngJ4RLxcXVS7b1EU1AQo+huZTMgTWXc4exUW WAc7wZDulEWBRBzsQ0eVpKw613gDNNdsAHlqwbEV3Fz2M3oChCTkBYug+FmWBjgART5u UuOg== 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=+mVEWzBYbxNsPTC4LhYIO4HlW1rrZO7Aog0YjWTPMts=; b=vaGypflCQd9z5zepa5+HUlwpPxP2o8h1J43q/b92otPa3N16ebU55VnekrMKpS44Ns 5TlCpom+xWkvS15antbob8BMUl7qgx3s0d2EP/uP/YyyzM2NARvsRF1pnj65+JTX9jH0 7Sq2WL8iSxFkrQv8IIwit3N6gauMlT7uWI+mziasUzCPwvZb5gpXo5iMI8PIZ2I2pfI8 8mrSpj5k2+H9W6qisT/WSeSOh9v9iumlF10qbAFe2dm2KzovbbM5yzEDh2eGZ5yjgnth eJGRtjcuXp4i1+/SeII3DxYX3Yi9wznX0g+kG7eUyCS3pvtkmm9pEva6utCtmzVNKJEA MnKA== X-Gm-Message-State: AO0yUKUISghNJVB6zzfEqnk+ekJ8gcZxK71ivUjA4poivArICaSNCjyy KvXoiLQcXC4NPFeJ9RWlwoSpCCiz+KKZG6TnUIY= X-Google-Smtp-Source: AK7set+oOqhdz9noRqYgDS+xSDfo5bYmHdTrB67A0qeAy90aGB5cpkICF13Wg/5hg0VobM5RHzXrzw== X-Received: by 2002:a17:907:208c:b0:878:8249:bef6 with SMTP id pv12-20020a170907208c00b008788249bef6mr15201303ejb.59.1676068920774; Fri, 10 Feb 2023 14:42:00 -0800 (PST) Received: from ubuntu-focal.. ([2a01:4f9:3a:1e26::2]) by smtp.gmail.com with ESMTPSA id c15-20020a17090603cf00b0088bd62b1cbbsm2976956eja.192.2023.02.10.14.41.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Feb 2023 14:42:00 -0800 (PST) From: Philipp Tomsich To: gcc-patches@gcc.gnu.org Cc: Kito Cheng , Christoph Muellner , Palmer Dabbelt , Andrew Waterman , Vineet Gupta , Philipp Tomsich Subject: [RFC PATCH v1 07/10] RISC-V: Recognize bexti in negated if-conversion Date: Fri, 10 Feb 2023 23:41:47 +0100 Message-Id: <20230210224150.2801962-8-philipp.tomsich@vrull.eu> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230210224150.2801962-1-philipp.tomsich@vrull.eu> References: <20230210224150.2801962-1-philipp.tomsich@vrull.eu> MIME-Version: 1.0 X-Spam-Status: No, score=-12.0 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 Zicond (andi + czero.nez) 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. gcc/ChangeLog: * config/riscv/zicond.md: Add split to reassociate "andi + seqz + neg" into "bexti + addi". Signed-off-by: Philipp Tomsich --- gcc/config/riscv/zicond.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gcc/config/riscv/zicond.md b/gcc/config/riscv/zicond.md index 15fdaa539f1..0aad61c7009 100644 --- a/gcc/config/riscv/zicond.md +++ b/gcc/config/riscv/zicond.md @@ -143,3 +143,13 @@ (define_split { 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_ZICOND && 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)))])