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.129.124]) by sourceware.org (Postfix) with ESMTPS id 8D25A3857034 for ; Fri, 3 Jun 2022 10:38:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8D25A3857034 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-477-cIaqwmPxM3aLbVHAg5FUVw-1; Fri, 03 Jun 2022 06:38:39 -0400 X-MC-Unique: cIaqwmPxM3aLbVHAg5FUVw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E7C128027EE; Fri, 3 Jun 2022 10:38:38 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.33.36.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A54992026D64; Fri, 3 Jun 2022 10:38:38 +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 253AcaGH2546588 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 3 Jun 2022 12:38:36 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 253AcZ2q2546587; Fri, 3 Jun 2022 12:38:35 +0200 Date: Fri, 3 Jun 2022 12:38:35 +0200 From: Jakub Jelinek To: Uros Bizjak Cc: "gcc-patches@gcc.gnu.org" Subject: Re: [PATCH] i386: Fix up *_doubleword_mask [PR105825] Message-ID: Reply-To: Jakub Jelinek References: MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 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:38:43 -0000 On Fri, Jun 03, 2022 at 12:23:36PM +0200, Uros Bizjak wrote: > I think it is better to leave the operation in its natural mode and > leave the peephole pass to do its magic, depending on the target. So like this? 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, use operands[2] mode for the AND operation instead of always SImode. * 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:33:38.180448918 +0200 @@ -11934,8 +11934,16 @@ (define_insn_and_split "*ashl3_doub if ((INTVAL (operands[3]) & (( * BITS_PER_UNIT) - 1)) != (( * BITS_PER_UNIT) - 1)) { - rtx tem = gen_reg_rtx (SImode); - emit_insn (gen_andsi3 (tem, operands[2], operands[3])); + rtx tem = gen_reg_rtx (GET_MODE (operands[2])); + rtx (*gen) (rtx, rtx, rtx); + switch (GET_MODE (operands[2])) + { + case E_HImode: gen = gen_andhi3; break; + case E_SImode: gen = gen_andsi3; break; + case E_DImode: gen = gen_anddi3; break; + default: gcc_unreachable (); + } + emit_insn (gen (tem, operands[2], operands[3])); operands[2] = tem; } @@ -12899,8 +12907,16 @@ (define_insn_and_split "*3_do if ((INTVAL (operands[3]) & (( * BITS_PER_UNIT) - 1)) != (( * BITS_PER_UNIT) - 1)) { - rtx tem = gen_reg_rtx (SImode); - emit_insn (gen_andsi3 (tem, operands[2], operands[3])); + rtx tem = gen_reg_rtx (GET_MODE (operands[2])); + rtx (*gen) (rtx, rtx, rtx); + switch (GET_MODE (operands[2])) + { + case E_HImode: gen = gen_andhi3; break; + case E_SImode: gen = gen_andsi3; break; + case E_DImode: gen = gen_anddi3; break; + default: gcc_unreachable (); + } + emit_insn (gen (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