public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/113281] [14 Regression] Wrong code due to vectorization of shift reduction and missing promotions since r14-3027
Date: Wed, 24 Jan 2024 09:52:59 +0000	[thread overview]
Message-ID: <bug-113281-4-v7lgW1XfVd@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-113281-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113281

--- Comment #18 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #17)
> (In reply to rguenther@suse.de from comment #16)
> > On Wed, 24 Jan 2024, pinskia at gcc dot gnu.org wrote:
> > 
> > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113281
> > > 
> > > --- Comment #15 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
> > > (In reply to Richard Biener from comment #14)
> > > > a >= 16 ? 0 : 32872 >> MIN (a, 15) (the MIN is still required to
> > > > avoid requiring masking).
> > > 
> > > Note maybe instead of MIN here we use `a & 0xf` since that will more likely be
> > > cheaper than a MIN.
> > 
> > But it's incorrect (that's what I did originally).
> 
> But `(a>= 16)? 0: (32872>> (a&0xf))` is correct.
> 
> So is `(a>=16 ? 0 : 32872) >> ( a & 0xf)` .
> 
> Or is it you want to avoid the conditional here.

I believe the thing is that Richi's PR110838 changes for RSHIFT_EXPR are
correct for arithmetic right shifts and we should keep doing what it does for
those.
But they are not correct for logical right shifts and they don't handle left
shifts.
Both logical right shifts and left shifts need to get 0 from the shift counts
bigger than new_precision - 1, which can be achieved through one of (or <<
instead of >>):
(op1 >= min_precision ? 0 : op0) >> (op1 & (min_precision - 1))
(op0 & (op1 < min_precision ? -1 : 0)) >> (op1 & (min_precision - 1))
op1 >= min_precision ? 0 : (op0 >> (op1 & (min_precision - 1)))
(op0 >> (op1 & (min_precision - 1))) & (op1 < min_precision ? -1 : 0)
Which one of these is best?
For simplicity of vect_recog_over_widening_pattern probably the first one,
unsure
about what generates best code (and where).

  parent reply	other threads:[~2024-01-24  9:53 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-08 19:17 [Bug target/113281] New: [14] RISC-V rv64gcv_zvl256b vector: Runtime mismatch with rv64gc patrick at rivosinc dot com
2024-01-08 19:20 ` [Bug target/113281] " patrick at rivosinc dot com
2024-01-08 21:49 ` rdapp at gcc dot gnu.org
2024-01-09  1:32 ` juzhe.zhong at rivai dot ai
2024-01-09  2:06 ` juzhe.zhong at rivai dot ai
2024-01-09  2:08 ` juzhe.zhong at rivai dot ai
2024-01-09  2:12 ` [Bug tree-optimization/113281] " pinskia at gcc dot gnu.org
2024-01-09  2:16 ` pinskia at gcc dot gnu.org
2024-01-09  2:17 ` juzhe.zhong at rivai dot ai
2024-01-09  2:58 ` [Bug tree-optimization/113281] [14 Regression] Wrong code due to vectorization of shift reduction and missing promotions pinskia at gcc dot gnu.org
2024-01-09  2:59 ` pinskia at gcc dot gnu.org
2024-01-09  8:32 ` rguenth at gcc dot gnu.org
2024-01-10 13:26 ` rguenth at gcc dot gnu.org
2024-01-12 12:16 ` cvs-commit at gcc dot gnu.org
2024-01-15 12:06 ` cvs-commit at gcc dot gnu.org
2024-01-23 16:58 ` [Bug tree-optimization/113281] [14 Regression] Wrong code due to vectorization of shift reduction and missing promotions since r14-3027 jakub at gcc dot gnu.org
2024-01-24  7:48 ` rguenth at gcc dot gnu.org
2024-01-24  7:54 ` pinskia at gcc dot gnu.org
2024-01-24  8:32 ` rguenther at suse dot de
2024-01-24  8:38 ` pinskia at gcc dot gnu.org
2024-01-24  9:52 ` jakub at gcc dot gnu.org [this message]
2024-01-24  9:54 ` rguenther at suse dot de
2024-01-24 10:00 ` jakub at gcc dot gnu.org
2024-01-24 13:23 ` jakub at gcc dot gnu.org
2024-01-24 20:49 ` rsandifo at gcc dot gnu.org
2024-01-29 12:33 ` cvs-commit at gcc dot gnu.org
2024-01-29 12:34 ` [Bug tree-optimization/113281] " rsandifo at gcc dot gnu.org
2024-01-31 17:30 ` [Bug tree-optimization/113281] [11/12/13 Regression] Latent wrong code due to vectorization of shift reduction and missing promotions since r9-1590 jakub at gcc dot gnu.org
2024-03-13 20:17 ` ewlu at rivosinc dot com
2024-03-13 20:22 ` pinskia at gcc dot gnu.org
2024-03-13 20:29 ` patrick at rivosinc dot com
2024-03-13 23:18 ` juzhe.zhong at rivai dot ai
2024-05-31  8:12 ` rdapp at gcc dot gnu.org
2024-05-31 14:56 ` cvs-commit at gcc dot gnu.org
2024-06-04  7:48 ` [Bug tree-optimization/113281] [11/12 " cvs-commit at gcc dot gnu.org
2024-06-04 12:47 ` [Bug tree-optimization/113281] [11 " cvs-commit at gcc dot gnu.org
2024-06-04 12:49 ` rsandifo at gcc dot gnu.org

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=bug-113281-4-v7lgW1XfVd@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).