From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by sourceware.org (Postfix) with ESMTPS id 806703AA88FD for ; Thu, 17 Nov 2022 15:25:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 806703AA88FD 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-x134.google.com with SMTP id d6so3315322lfs.10 for ; Thu, 17 Nov 2022 07:25:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=xAPCsJnt28jzcOC1+Kvkoyu6tQhbTvswwVrNvVucOKw=; b=JCc39OYxRCzg9XglCKsbF/2jKceFx1RITUY6TPaDAT/YqX6Ubvsk6mcdThsPvJuL8m z4GczuplhxOhaTjMb5ot2GC64a7v9uu5+bNmbEW1KDo3QkM4ToRcLezOt9A9uuJBMokt hd1TEtytkLHfVlxvk0Mu/gNWeQTbuo/PoL1j1gBsxhYx4DJ6WREqodsVJCKebTFz4kXv c8Z/FmLx9n/RouqhyW97tP1rwIg2B9Z8LNfs4x/JLAwPvqtnwb/Bznikm0hyj/X6OCqg oPpPsxuuYPjYv98E4ww1DXN8B937jTXiz5L+M9OhDm3aN6yWM5OM77zasWvgaRBElHeD UL+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=xAPCsJnt28jzcOC1+Kvkoyu6tQhbTvswwVrNvVucOKw=; b=yTOFqRX2hbE2sWuprAMUkSoDelYC4GpmXPD2FATpRETZOc3wZwJaya0oAtv0mIwn4L jmk5e4swmTnrmP07PhKSVQqljxuuCPv2Gxdr9wv36llp1VBWEl7y1j2v/nfpwU3kr/Ro upi74RFA5H4Qyfg7Dff1Vy/axR672U5jl9rRO4YXA93347bOGS4FJllzNfpPWm4sGmIK mxy4ZYQ6q4LLc5/I1DE7gUKts4DmbXtowQS8FZfIvRsWsfW/wi4T4h4f/YyZ2vFCaenm 2uoaH0mA84LPxHLiFtlcM87UWo75Urwr4UqHwNBXTKy3dQ9k/NYHzoDcupC1LqJx1exn +f/g== X-Gm-Message-State: ANoB5pnQCYveGvD0sdoh62BMGfm7XSz7PjLlrypbujn/7Ke7STkK+1EO a0jfRJtyVQebK1iUBBQ/Md9juseG6PcEYsbVvcAqwA== X-Google-Smtp-Source: AA0mqf40w3Y79T1jRf4UIJPYryKX2bBLkfdQqWI2WW2Xri+sQKbfkFByz7P21x15g99ztHQ5lrqjqlLVftK1eMSVPTA= X-Received: by 2002:ac2:47e3:0:b0:4b4:1324:6ed3 with SMTP id b3-20020ac247e3000000b004b413246ed3mr1030533lfp.19.1668698716024; Thu, 17 Nov 2022 07:25:16 -0800 (PST) MIME-Version: 1.0 References: <20221108195547.2701347-1-philipp.tomsich@vrull.eu> <9b0f6fb5-a2e6-3064-5c77-f3357a0a3344@gmail.com> In-Reply-To: <9b0f6fb5-a2e6-3064-5c77-f3357a0a3344@gmail.com> From: Philipp Tomsich Date: Thu, 17 Nov 2022 16:25:04 +0100 Message-ID: Subject: Re: [PATCH] RISC-V: bitmanip: use bexti for "(a & (1 << BIT_NO)) ? 0 : -1" To: Jeff Law Cc: gcc-patches@gcc.gnu.org, Kito Cheng , Christoph Muellner , Vineet Gupta , Jeff Law , Palmer Dabbelt Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,JMQ_SPF_NEUTRAL,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Committed to master. Thanks! Philipp. On Thu, 17 Nov 2022 at 15:43, Jeff Law wrote: > > > 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 > >