From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) by sourceware.org (Postfix) with ESMTPS id B223F3838202 for ; Fri, 3 Jun 2022 11:11:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B223F3838202 Received: by mail-qt1-x829.google.com with SMTP id 2so5286705qtw.0 for ; Fri, 03 Jun 2022 04:11:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eM6BSPZfeHFUBDbx7sNijWOfBjh1E9WJRSIxixH7Ulc=; b=kyJRycoLrghaK/RYfK+0QPzWBfcCnV8moRvtir81FEoIrV8Ym2cY7F/RLlO5UJBfkW NXHd5mcZPbEnlpnpt7Q2VI9OkH67JqPcsVI7XKOo3CEKcJgt3ahKx7qTc3f28Xe+9aFo 537ZOh6zZqDJxYYwkXsZ3hHBtG4BBkPbE2/EKWdqJVxwM18DVEBwnSpLFj9J7R9tWjjq e74CreLObbyMQK8EIhaeP5FxERzS5g2U7JXZ09LDrXZNEkDS2L5idpz/DgtVQS2JpK6r brn1zCkXkBnSeQ/MNWl7sc5l5z4yRGVMlOzbOp1pH0t1gTaZO1ffBBRqnq3UoLTb4iHS iTWw== X-Gm-Message-State: AOAM530LWd8bgVnpV/7hQbLFprZHC49l8GKdu4M+ESRXfA8DCD5o8fVI nM+DDWUIvxrl2B2NC5idX2RvF2QFYu0gfxdP4QM= X-Google-Smtp-Source: ABdhPJz1fZWoPrVIkzQ8fyB3wFOhU7UwFKcgt/F3pY2o6A5QefL23ga2nfxazauDP/Hzs4ierSvMIbGHBVyLlv4BtwM= X-Received: by 2002:ac8:5a96:0:b0:303:397:48e9 with SMTP id c22-20020ac85a96000000b00303039748e9mr6833065qtc.57.1654254666989; Fri, 03 Jun 2022 04:11:06 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Uros Bizjak Date: Fri, 3 Jun 2022 13:10:55 +0200 Message-ID: Subject: Re: [PATCH] i386: Fix up *_doubleword_mask [PR105825] To: Jakub Jelinek Cc: "gcc-patches@gcc.gnu.org" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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 11:11:09 -0000 On Fri, Jun 3, 2022 at 12:38 PM Jakub Jelinek wrote: > > 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? You can use ix86_expand_binary_operator. > 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. OK with using ix86_expand_binary_operator. Thanks, Uros. > > --- 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 >