From patchwork Sun May 21 17:12:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georg-Johann Lay X-Patchwork-Id: 96891 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp976790vqo; Sun, 21 May 2023 10:13:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ513HdYGR7AEcsEmffXjBoDlepG83be7GPzwNODyS1uy6EVedqXzwKmKpAltTIh5iZqtsTJ X-Received: by 2002:a17:907:7f8c:b0:96a:f8ec:c311 with SMTP id qk12-20020a1709077f8c00b0096af8ecc311mr6816598ejc.36.1684689181248; Sun, 21 May 2023 10:13:01 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id lg7-20020a170906f88700b0094f8aa49c6bsi2090515ejb.472.2023.05.21.10.13.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 May 2023 10:13:01 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=fail header.i=@gjlay.de header.s=strato-dkim-0002 header.b=FWFjJpIc; dkim=neutral (no key) header.i=@gjlay.de; arc=fail (signature failed); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 05F1E3858C74 for ; Sun, 21 May 2023 17:12:55 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mo4-p00-ob.smtp.rzone.de (mo4-p00-ob.smtp.rzone.de [81.169.146.163]) by sourceware.org (Postfix) with ESMTPS id 6AE543858D20 for ; Sun, 21 May 2023 17:12:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6AE543858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gjlay.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=gjlay.de ARC-Seal: i=1; a=rsa-sha256; t=1684689147; cv=none; d=strato.com; s=strato-dkim-0002; b=BDtMQXbxz9lM1nPMc0Yv00S2QDTKOq30xtWVl9lzdOuHCsg7bVIqpYN4tWhcLRqxTi 5Im3R4r+xZXnenF7cysEf4KaaTa6gA53t5Glf65ZwuEXnFvuC4Nfgow3Q0gSAsjw4TiK MR+5jNFlOPIBKtZc55L4NRZE2R9FrPC+CQeeKWaseze1bDoMUhqdA0SwC9fMb14pM9Hv ipu4kvBbVQxthdeOPC6dKl7H9KQ4kVcwbL969zHlhATAWlKJ2eyt339gNZzbid81C2dZ 0a9+BywssVXbihIS27vY3IrhQjnNs9EyauLFyq+9fiAAgkh5WKUfkJd4l97q9qofvGZi y1NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1684689147; s=strato-dkim-0002; d=strato.com; h=Subject:From:To:Date:Message-ID:Cc:Date:From:Subject:Sender; bh=gJHqzWiwKYjcNxdu813T/0hG8OVQpNZ5VoByiCM0H2Q=; b=rWecCZ2nYvkhSK6oKKjRd4MCVg81tzPKAI956pJoqBdIM1GwOPRREtkvSdVMKkwu5H hkns51ygDrb2bgDJoXIpm/kqxR3RxCoyPhadQY0BJ5EDQzVyhiHDuX6O7Hd9XhBmFHhE 1iqHOMHZDNpRiG3tX/rXPwvb+0UBLPSyl+O0Fs104LSDJcopjHenirblt8ymW3fSwjHA ECeCDhrarshUr1F3qrbQWDFJMAuNOHPApSUL0zneFmuqjBAWo8gbJIVKD/mzF8OxoB/P HCWUcUfZbhax/Xeb1X3P8eJpqEAnofqu6Glod8f7HOMhTj2wTeTKz8VMnS32tXUv9bWW X2zA== ARC-Authentication-Results: i=1; strato.com; arc=none; dkim=none X-RZG-CLASS-ID: mo00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1684689147; s=strato-dkim-0002; d=gjlay.de; h=Subject:From:To:Date:Message-ID:Cc:Date:From:Subject:Sender; bh=gJHqzWiwKYjcNxdu813T/0hG8OVQpNZ5VoByiCM0H2Q=; b=FWFjJpIcp7S9d8U0a9d0/d4pvf127vFkIoaZdamZvq6EZUT1deaeAIP0NnCKG/YcDR bVkyV52Ve1zJkNSGdTX0MDqZxNp4ntr6AF5L65XH7VQaFVcC0WxLENAEv8CraPvYA2XX dOChLlUNv+qlFoA35HqzX7KyENzCeOsjsxH4viaEJHjFwfZrO20yCRkQOrJpPq4bhgph gPlEkbsx4pHABOwV5O2kPY0b72p9hW4z2XioB23mUieeF3SrslfSXjJ0sa+tFo8Mw3TN SYBTgzsR38MnVyAhuJwLaJxhi4+GAtbN7f4hdgDlH/N6RInzDA+KAEDzSzgLT7iZ/ky5 iiYQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; t=1684689147; s=strato-dkim-0003; d=gjlay.de; h=Subject:From:To:Date:Message-ID:Cc:Date:From:Subject:Sender; bh=gJHqzWiwKYjcNxdu813T/0hG8OVQpNZ5VoByiCM0H2Q=; b=/Juug6Ft1wAI6ZmvUcxLFYkfQZMpCo94CyFFQNvwqf6e6c4m6B5PdMtr+zS9XLgagu qSWS6l77ptHiXhDmCxDw== X-RZG-AUTH: ":LXoWVUeid/7A29J/hMvvT3koxZnKT7Qq0xotTetVnKkRmM69o2y+LiO3MutATA==" Received: from [192.168.2.102] by smtp.strato.de (RZmta 49.4.0 DYNA|AUTH) with ESMTPSA id z691f1z4LHCQTb3 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate) for ; Sun, 21 May 2023 19:12:26 +0200 (CEST) Message-ID: Date: Sun, 21 May 2023 19:12:16 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Content-Language: en-US To: gcc-patches@gcc.gnu.org From: Georg-Johann Lay Subject: [avr,committed] Fix PR90622 X-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766524643128244575?= X-GMAIL-MSGID: =?utf-8?q?1766524643128244575?= This patch fixes a minor optimization issue for an avr specific builtin. Applied as obvious. https://gcc.gnu.org/r14-1025 Johann --- target/90622: __builtin_avr_insert bits: Use BLD/BST for one bit in place. If just one bit is inserted in the same position like with: __builtin_avr_insert_bits (0xFFFFF2FF, src, dst); a BLD/BST sequence is better than XOR/AND/XOR. Thus, don't fold that case to the latter sequence. gcc/ PR target/90622 * config/avr/avr.cc (avr_fold_builtin) [AVR_BUILTIN_INSERT_BITS]: Don't fold to XOR / AND / XOR if just one bit is copied to the same position. tree tres, tmask = build_int_cst (val_type, mask_f ^ 0xff); diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc index d5af40f7091..9fa50ca230d 100644 --- a/gcc/config/avr/avr.cc +++ b/gcc/config/avr/avr.cc @@ -14425,10 +14425,13 @@ avr_fold_builtin (tree fndecl, int n_args ATTRIBUTE_UNUSED, tree *arg, if (changed) return build_call_expr (fndecl, 3, tmap, tbits, tval); - /* If bits don't change their position we can use vanilla logic - to merge the two arguments. */ + /* If bits don't change their position, we can use vanilla logic + to merge the two arguments... */ - if (avr_map_metric (map, MAP_NONFIXED_0_7) == 0) + if (avr_map_metric (map, MAP_NONFIXED_0_7) == 0 + // ...except when we are copying just one bit. In that + // case, BLD/BST is better than XOR/AND/XOR, see PR90622. + && avr_map_metric (map, MAP_FIXED_0_7) != 1) { int mask_f = avr_map_metric (map, MAP_MASK_PREIMAGE_F);