public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew Stubbs <ams@baylibre.com>
To: Hongtao Liu <crazylht@gmail.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] vect: Use xor to invert oversized vector masks
Date: Fri, 15 Mar 2024 09:52:57 +0000	[thread overview]
Message-ID: <4ec19899-3cae-4e0b-a832-d71b644ba9ce@baylibre.com> (raw)
In-Reply-To: <CAMZc-byMooK2gyO0NG1J2O9mgPCwkNHsr_8isBiRNPV7PDdg_A@mail.gmail.com>

On 15/03/2024 03:45, Hongtao Liu wrote:
> On Thu, Mar 14, 2024 at 11:42 PM Andrew Stubbs <ams@baylibre.com> wrote:
>>
>> Don't enable excess lanes when inverting vector bit-masks smaller than the
>> integer mode.  This is yet another case of wrong-code due to mishandling
>> of oversized bitmasks.
>>
>> This issue shows up in vect/tsvc/vect-tsvc-s278.c and
>> vect/tsvc/vect-tsvc-s279.c if I set the preferred vector size to V32
>> (down from V64) on amdgcn.
>>
>> OK for mainline?
>>
>> Andrew
>>
>> gcc/ChangeLog:
>>
>>          * expr.cc (expand_expr_real_2): Use xor to invert vector masks.
>> ---
>>   gcc/expr.cc | 11 +++++++++++
>>   1 file changed, 11 insertions(+)
>>
>> diff --git a/gcc/expr.cc b/gcc/expr.cc
>> index 403eeaa108e4..3540327d879e 100644
>> --- a/gcc/expr.cc
>> +++ b/gcc/expr.cc
>> @@ -10497,6 +10497,17 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode,
>>                                 immed_wide_int_const (mask, int_mode),
>>                                 target, 1, OPTAB_LIB_WIDEN);
>>          }
>> +      /* If it's a vector mask don't enable excess bits.  */
>> +      else if (VECTOR_BOOLEAN_TYPE_P (type)
>> +              && SCALAR_INT_MODE_P (mode)
>> +              && maybe_ne (GET_MODE_PRECISION (mode),
>> +                           TYPE_VECTOR_SUBPARTS (type).to_constant ()))
>> +       {
>> +         auto nunits = TYPE_VECTOR_SUBPARTS (type).to_constant ();
>> +         temp = expand_binop (mode, xor_optab, op0,
>> +                              GEN_INT ((HOST_WIDE_INT_1U << nunits) - 1),
>> +                              target, true, OPTAB_WIDEN);
>> +       }
> Not review, just curious, should the issue be fixed by the commit in PR113576.
> Also wonder besides cbranch, excess land bits also matter?
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113576#c35

It does seem to be another case of the same problem, but those commits 
are long enough ago that I do have them, and still saw a problem.

Andrew


      parent reply	other threads:[~2024-03-15  9:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-14 15:41 Andrew Stubbs
2024-03-15  3:45 ` Hongtao Liu
2024-03-15  7:35   ` Richard Biener
2024-03-15 11:24     ` Andrew Stubbs
2024-03-15 13:10       ` Richard Biener
2024-03-15  9:52   ` Andrew Stubbs [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4ec19899-3cae-4e0b-a832-d71b644ba9ce@baylibre.com \
    --to=ams@baylibre.com \
    --cc=crazylht@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).