From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by sourceware.org (Postfix) with ESMTPS id 82546395C06E for ; Wed, 16 Nov 2022 20:01:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 82546395C06E 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-lj1-x22e.google.com with SMTP id h12so23269193ljg.9 for ; Wed, 16 Nov 2022 12:01:41 -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=p+BKvDC2tVNE8C9SkVTCdwHkGT+uwm4nhn90pJg0Hvc=; b=r5fZFCoYpY05nttBoWf3LQX95CTv/3VvyFNPjEYofjspOlj7O+S66G278atyDmTPmh z1YyDfNEPgECkKTvkj+LuxXQqYK/nhQeKW/UUwNVtvPEQC+mqFv0V8xBu1Ofbd3n2G3n LLK57wrUau6r9loqst/SHpX2ocyyD/uEWEoWO0egPjYWKM1xPHKtXs0eqFgahQVU7WE9 MoG9EBvXmCXqV+Z1ssbY/37ESc9qmKJ92K4L2z27Bi4OPsLc29GsRHD1KS3qcmCNmABg KseKaEvWOP52fHJ5VIsYR2yzbnIv2uaA994Zd4bQxXi3JLztPu5kympc4OSF2Apg8hbq ZOCQ== 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=p+BKvDC2tVNE8C9SkVTCdwHkGT+uwm4nhn90pJg0Hvc=; b=ugYe9Vc3cuCXcnQ91Z1RM2FBIKI2pQ5TKS4mcSFSBxVprScig6uEuFKtozqvrHWfGR sWa2+ffS3QylG2QI0z5voQt06ZZkpFS1RGOi9xXrwpjq7KuWoWjqqDxW3fgvwkC9ktPj s3cT0tZBWAYYQLDRzyciMZmtSeAypMSWd7LWsGCWfDFGlyuraChsKomBFnAw3zBzTxL9 mBpoKvzx1p+kvmBPlnHWE5pOD0yq17HzgBnjpPZsiI4Pr3gPAPttNX6K5sfMEgZ8WtsK DLYRxHrMBbsUElevi+j6nL64+mfWhA2LuWqiI05DqUVVzepzXc6Y1br5+n1Ny9SgaEkg LFuQ== X-Gm-Message-State: ANoB5pngpnTanJ+NwSQZFGp4oRLdDi2GNrnKAYX1xG9xe8lG2OnU83xb vje2hO4iyeNOQZGtj3284ZC7f4WK/I9D4T+yOsLLUQ== X-Google-Smtp-Source: AA0mqf6ydLlWdsghDQvFpdZhuHPV2O1sLm2HVfDmukOm+u8cy1Nrn81L5SbzJtxzoH+nfr+PNpv+7N9lSyRM2zA0A7g= X-Received: by 2002:a05:651c:11cb:b0:26e:6fb:4845 with SMTP id z11-20020a05651c11cb00b0026e06fb4845mr7894286ljo.120.1668628900023; Wed, 16 Nov 2022 12:01:40 -0800 (PST) MIME-Version: 1.0 References: <20221113204840.4062092-1-philipp.tomsich@vrull.eu> <391fc4c2-9817-5e36-643c-b32fc635f6dd@gmail.com> In-Reply-To: <391fc4c2-9817-5e36-643c-b32fc635f6dd@gmail.com> From: Philipp Tomsich Date: Wed, 16 Nov 2022 21:01:28 +0100 Message-ID: Subject: Re: [PATCH] RISC-V: Split "(a & (1UL << bitno)) ? 0 : -1" to bext + addi To: Jeff Law Cc: gcc-patches@gcc.gnu.org, Vineet Gupta , Kito Cheng , Christoph Muellner , Jeff Law , Palmer Dabbelt Content-Type: multipart/alternative; boundary="000000000000d920e405ed9bf06c" X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HTML_MESSAGE,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: --000000000000d920e405ed9bf06c Content-Type: text/plain; charset="UTF-8" Applied to master. Thanks! Philipp. On Tue, 15 Nov 2022 at 18:25, Jeff Law wrote: > > On 11/13/22 13:48, Philipp Tomsich wrote: > > For a straightforward application of bext for the following function > > long bext64(long a, char bitno) > > { > > return (a & (1UL << bitno)) ? 0 : -1; > > } > > we generate > > srl a0,a0,a1 # 7 [c=4 l=4] lshrdi3 > > andi a0,a0,1 # 8 [c=4 l=4] anddi3/1 > > addi a0,a0,-1 # 14 [c=4 l=4] adddi3/1 > > due to the following failed match at combine time: > > (set (reg:DI 82) > > (zero_extract:DI (reg:DI 83) > > (const_int 1 [0x1]) > > (reg:DI 84))) > > > > The existing pattern for bext requires the 3rd argument to > > zero_extract to be a QImode register wrapped in a zero_extension. > > This adds an additional pattern that allows an Xmode argument. > > > > With this change, the testcase compiles to > > bext a0,a0,a1 # 8 [c=4 l=4] *bextdi > > addi a0,a0,-1 # 14 [c=4 l=4] adddi3/1 > > > > gcc/ChangeLog: > > > > * config/riscv/bitmanip.md (*bext): Add an additional > > pattern that allows the 3rd argument to zero_extract to be > > an Xmode register operand. > > > > gcc/testsuite/ChangeLog: > > > > * gcc.target/riscv/zbs-bext.c: Add testcases. > > * gcc.target/riscv/zbs-bexti.c: Add testcases. > > It's fairly common to want variants with extraction as well as a simple > register operand. The biggest concern is typically around > SHIFT_COUNT_TRUNCATED, but given we already have an extract variant > y'all should have already addressed concerns around SHIFT_COUNT_TRUNCATED. > > OK. > > jeff > > > --000000000000d920e405ed9bf06c--