From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by sourceware.org (Postfix) with ESMTPS id E25123AA9806 for ; Thu, 17 Nov 2022 14:43:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E25123AA9806 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-x536.google.com with SMTP id 130so2149177pgc.5 for ; Thu, 17 Nov 2022 06:43:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=GvIwWeryrjMXYqim3EB9fhMy4lLd2dqB0QOQsVYA49g=; b=FmwKoLGN8sQm9haoCvN8CCYGhlPNxJ1Z2m2ATwrmkJjP5LbGDL82A/9W12KKg6dnIa NAzu0m03/RmhWtsiuygnYtiKwMzT3vOMmBGlA3ChNp0toL640KodQ9R0ekUUt7Uvz2Fy jst49neSTSYLk3dkRCbFqm4DJES1W8YP9LcLUvh2BkouBHVU2Olvn7narwxdw9sz17Rt cPYSXBDe5JfidrPnCv7DndYFCDMwaHe2knrZjtXIcBNepV31uOlJU4vJirFdflC4gg/p zZcwwJAoqMP4psSn7SaOlzGHdRMbBpoXYDsPmh8i3mDfG3kGg9Qj/QoeIjmuIwIIngHC L0XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GvIwWeryrjMXYqim3EB9fhMy4lLd2dqB0QOQsVYA49g=; b=jW/4mcbi+8xpeaNHLMqQioCGFWB8Efv0ayaaOGnODMSeygF0RfdQoPJR6niBkVNFwk yTTOGJFNdS+/s0wj53LBLYr3o1VNxiE5jgSCfjvT6WUzEQ+N4HbibJtMKbdcyeA3nmIj zAqsAXHAw8Tv0ejxaNhHiuE85uNd8wy6wHGjXkweoOSLGPcpUba1JitL7Lwtz5GYS/zE qNBTelvvu4ysupc6dZstix3XAdxAnRFZJ4Yovr49p2SM/2+43req2WyPs+I1nrIRpZkQ 9nIHMQ6Ny5zms2GgmfnMuMMbAQMSkcP82vfUYOqd/1q0jD7vB+N25U5H+tIg8OiLifcY UrIQ== X-Gm-Message-State: ANoB5ploLkHekUiELLc97B78XjxaxfSMEFNpHAzPKnexgYlZ00sQd1kh ENVScFxDkRo4mB2rlh51BFo= X-Google-Smtp-Source: AA0mqf58Y3DPhSfkRZjLN7ZeL+UkqOvtaDi9xJCC7ygWw+KtT4hSZ4IM9Pe+kR/Mlge7VvCdpzRE8w== X-Received: by 2002:aa7:84c5:0:b0:56b:f64b:b385 with SMTP id x5-20020aa784c5000000b0056bf64bb385mr3186967pfn.68.1668696224779; Thu, 17 Nov 2022 06:43:44 -0800 (PST) Received: from ?IPV6:2601:681:8600:13d0::f0a? ([2601:681:8600:13d0::f0a]) by smtp.gmail.com with ESMTPSA id mr9-20020a17090b238900b00203ab277966sm3700826pjb.7.2022.11.17.06.43.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Nov 2022 06:43:44 -0800 (PST) Message-ID: <9b0f6fb5-a2e6-3064-5c77-f3357a0a3344@gmail.com> Date: Thu, 17 Nov 2022 07:43:42 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Subject: Re: [PATCH] RISC-V: bitmanip: use bexti for "(a & (1 << BIT_NO)) ? 0 : -1" Content-Language: en-US To: Philipp Tomsich , gcc-patches@gcc.gnu.org Cc: Kito Cheng , Christoph Muellner , Vineet Gupta , Jeff Law , Palmer Dabbelt References: <20221108195547.2701347-1-philipp.tomsich@vrull.eu> From: Jeff Law In-Reply-To: <20221108195547.2701347-1-philipp.tomsich@vrull.eu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,NICE_REPLY_A,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 List-Id: On 11/8/22 12:55, Philipp Tomsich wrote: > Consider creating a polarity-reversed mask from a set-bit (i.e., if > the bit is set, produce all-ones; otherwise: all-zeros). Using Zbb, > this can be expressed as bexti, followed by an addi of minus-one. To > enable the combiner to discover this opportunity, we need to split the > canonical expression for "(a & (1 << BIT_NO)) ? 0 : -1" into a form > combinable into bexti. > > Consider the function: > long f(long a) > { > return (a & (1 << BIT_NO)) ? 0 : -1; > } > This produces the following sequence prior to this change: > andi a0,a0,16 > seqz a0,a0 > neg a0,a0 > ret > Following this change, it results in: > bexti a0,a0,4 > addi a0,a0,-1 > ret > > gcc/ChangeLog: > > * config/riscv/bitmanip.md: Add a splitter to generate > polarity-reversed masks from a set bit using bexti + addi. > > gcc/testsuite/ChangeLog: > > * gcc.target/riscv/zbs-bexti.c: New test. OK Jeff