From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by sourceware.org (Postfix) with ESMTPS id 4833B3858D38 for ; Sat, 24 Sep 2022 18:38:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4833B3858D38 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-pj1-x1029.google.com with SMTP id fs14so2886412pjb.5 for ; Sat, 24 Sep 2022 11:38:23 -0700 (PDT) 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; bh=Z7gf8JTNRCvX4XbNnXffgoJqTWCiD6obaeQYhnUa5vE=; b=MGOtCIfKRw3AB9Vw4O8D09CXP7H85RMuCcf0x4lzHSTdwO7mUJLL/vMC6iBOhgJ1MY K56TG3UDvtG9jZtSg6JCHnaTeUl3/YxKtzHXXvYEwayBL8uTnnYoOnkFBX1wT7wKbeRN /ZZNzq/H1KTD5XTZERUCebiWZcPsZvZUfwjIH/puzXsUH2rpj+Te++99bsJ/J5y38bAA S85OgP+niVz5mIcNtXmBN6omgjeahHSf7YvR5/ZjAe5NfNOQMRvlY6rA55daxU1fV5JW DYuCdTREQdIOOHdVwnT+m4tUkLaWdMLjQaaBaPaYlIT2EtYK9zbVaX9hyBkjrit6EOCg jIeA== 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; bh=Z7gf8JTNRCvX4XbNnXffgoJqTWCiD6obaeQYhnUa5vE=; b=hzoKZ/TGC9UxzRqC9vq1ocavuP/X2axS90vXzUMWdiGBZuMIFFekyNp0y/SCcMyqgo 8K7zqWZfOraruTFaaFuFLNxzzbRT1rdfjeObntxjHZ7DVVc2X3fnrbxgEeIIC+9vt9wi mdzVP6YPe1Ag8E3fTkUyiQ6LwL5FNS6Jn6okViqolMPp8Ektp9vDw6IJDJqJp8lYFAk9 w7RA2SUmdDBsAcYXeGmfV748mB/vesRHWepGAd6jf+SUE4yG64FrWM9OaREu4YJ+xGjT WvghV5IOMOjZzF/tLqygoBORBJkavlmz0SIRslUQ5Ythdxvv/NIEldT746b0Unvag5V7 Veng== X-Gm-Message-State: ACrzQf0Suy6ExT5YFGGn5PKINsE2AVp7rzcVl1GHbc1bAh3NKPMw3Vk7 +pY/D9vn4M6h9p0H2ywSix/Xfs32HmrEDg== X-Google-Smtp-Source: AMsMyM7VBUf9HdqCrMWL/78l6EeBLBuRNZntXCvonWFnJoKV/APxYiBctUKQVQD35kR2/oTIjw33DQ== X-Received: by 2002:a17:90b:3883:b0:203:214d:4272 with SMTP id mu3-20020a17090b388300b00203214d4272mr27703636pjb.101.1664044702030; Sat, 24 Sep 2022 11:38:22 -0700 (PDT) Received: from ?IPV6:2601:681:8600:13d0::f0a? ([2601:681:8600:13d0::f0a]) by smtp.gmail.com with ESMTPSA id u3-20020a17090341c300b0016d6963cb12sm8213968ple.304.2022.09.24.11.38.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 24 Sep 2022 11:38:21 -0700 (PDT) Message-ID: <094ad28e-ac7f-686c-2e1c-6dc21a129173@gmail.com> Date: Sat, 24 Sep 2022 12:38:20 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Subject: Re: [PATCH 1/2]middle-end Fold BIT_FIELD_REF and Shifts into BIT_FIELD_REFs alone Content-Language: en-US To: Tamar Christina , gcc-patches@gcc.gnu.org Cc: nd@arm.com, rguenther@suse.de References: From: Jeff Law In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,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 9/23/22 05:42, Tamar Christina wrote: > Hi All, > > This adds a match.pd rule that can fold right shifts and bit_field_refs of > integers into just a bit_field_ref by adjusting the offset and the size of the > extract and adds an extend to the previous size. > > Concretely turns: > > #include > > unsigned int foor (uint32x4_t x) > { > return x[1] >> 16; > } > > which used to generate: > > _1 = BIT_FIELD_REF ; > _3 = _1 >> 16; > > into > > _4 = BIT_FIELD_REF ; > _2 = (unsigned int) _4; > > I currently limit the rewrite to only doing it if the resulting extract is in > a mode the target supports. i.e. it won't rewrite it to extract say 13-bits > because I worry that for targets that won't have a bitfield extract instruction > this may be a de-optimization. > > Bootstrapped Regtested on aarch64-none-linux-gnu, x86_64-pc-linux-gnu > and no issues. > > Testcase are added in patch 2/2. > > Ok for master? > > Thanks, > Tamar > > gcc/ChangeLog: > > * match.pd: Add bitfield and shift folding. Were you planning to handle left shifts as well?  It looks like it since you've got iterations for the shift opcode and corresponding adjustment to the field, but they currently only handle rshift/plus. Jeff