From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 30B4438387EC for ; Fri, 3 Jun 2022 10:17:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 30B4438387EC Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-380-65H4Zk4LOM-_ZofYEkEDEQ-1; Fri, 03 Jun 2022 06:17:40 -0400 X-MC-Unique: 65H4Zk4LOM-_ZofYEkEDEQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 70688101A54E; Fri, 3 Jun 2022 10:17:40 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.33.36.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3599340CF8E7; Fri, 3 Jun 2022 10:17:40 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 253AHbgn2545196 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 3 Jun 2022 12:17:38 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 253AHbn92545195; Fri, 3 Jun 2022 12:17:37 +0200 Date: Fri, 3 Jun 2022 12:17:37 +0200 From: Jakub Jelinek To: Uros Bizjak Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] i386: Fix up *_doubleword_mask [PR105825] Message-ID: Reply-To: Jakub Jelinek MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, 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: , X-List-Received-Date: Fri, 03 Jun 2022 10:17:43 -0000 Hi! My PR105778 patch apparently broke the following testcase. If the mask has the top relevant bit clear (i.e. we know we are shifting by 0 to wordsize bits - 1) but doesn't have all the bits below it set, we emit andsi3 before the shift sequence. When the pattern had :SI for that operand, that was just fine, but now that it can be also HImode or for -m64 DImode, we either can use a lowpart or paradoxical subreg to SImode as the following patch, or we could use a HImode or DImode AND. Ok for trunk if it passes bootstrap/regtest on x86_64-linux and i686-linux? 2022-06-03 Jakub Jelinek PR target/105825 * config/i386/i386.md (*ashl3_doubleword_mask, *3_doubleword_mask): If top bit of mask is clear, but lower bits of mask aren't all set and operands[2] doesn't have SImode, force it to get and use subreg to SImode for andsi3 operand. * gcc.dg/pr105825.c: New test. --- gcc/config/i386/i386.md.jj 2022-06-02 10:40:00.034660893 +0200 +++ gcc/config/i386/i386.md 2022-06-03 12:00:39.323292767 +0200 @@ -11935,6 +11935,11 @@ (define_insn_and_split "*ashl3_doub != (( * BITS_PER_UNIT) - 1)) { rtx tem = gen_reg_rtx (SImode); + if (GET_MODE (operands[2]) != SImode) + { + operands[2] = force_reg (GET_MODE (operands[2]), operands[2]); + operands[2] = gen_lowpart (SImode, operands[2]); + } emit_insn (gen_andsi3 (tem, operands[2], operands[3])); operands[2] = tem; } @@ -12900,6 +12905,11 @@ (define_insn_and_split "*3_do != (( * BITS_PER_UNIT) - 1)) { rtx tem = gen_reg_rtx (SImode); + if (GET_MODE (operands[2]) != SImode) + { + operands[2] = force_reg (GET_MODE (operands[2]), operands[2]); + operands[2] = gen_lowpart (SImode, operands[2]); + } emit_insn (gen_andsi3 (tem, operands[2], operands[3])); operands[2] = tem; } --- gcc/testsuite/gcc.dg/pr105825.c.jj 2022-06-03 12:01:58.008460659 +0200 +++ gcc/testsuite/gcc.dg/pr105825.c 2022-06-03 12:01:41.259637783 +0200 @@ -0,0 +1,13 @@ +/* PR target/105825 */ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-mavx" { target avx } } */ + +__int128 j; +int i; + +void +foo (void) +{ + j <<= __builtin_parityll (i); +} Jakub