public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/111770] predicated loads inactive lane values not modelled
Date: Thu, 22 Feb 2024 13:16:12 +0000	[thread overview]
Message-ID: <bug-111770-4-3u8okSGrRM@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-111770-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Alex Coplan from comment #4)
> (In reply to Richard Biener from comment #3)
> > Now, if-conversion could indeed elide the .COND_ADD for integers.  It's
> > problematic there only because of signed overflow undefinedness, so
> > you shouldn't see it for 'unsigned' already, and adding zero is safe.
> 
> Can you elaborate on this a bit? Do you mean to say that the .COND_ADD is
> only there to avoid if-conversion introducing UB due to signed overflow?

No, you are right.

> ISTM it's needed for correctness even without that, as the addend needn't be
> guaranteed to be zero in the general case.
> 
> > if-conversion would need to have an idea of all the ranges involved here
> > so it might be a bit sophisticated to get it right.
> 
> Does what I suggested above make any sense, or do you have in mind a
> different way of handling this in if-conversion? I'm wondering how ifcvt
> should determine that the addend is zero in the case where the predicate is
> false.

ifcvt would need to compute said fact, say, keep a lattice of the value
(or value-range) that's there when the block isn't executed (simulating
a disabled vector lane).  A load that's going to be replaced by a
.MASK_LOAD can be then known zero and this needs to be propagated through
regular stmts (like the multiply).  There's also .COND_* which if-conversion
could actually provide the else value for - like if we have a following
division to avoid dividing by zero.  But that would be propagating backwards
(I'd still have this usecase in mind).

  parent reply	other threads:[~2024-02-22 13:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-11 12:38 [Bug tree-optimization/111770] New: " tnfchris at gcc dot gnu.org
2023-10-11 12:58 ` [Bug tree-optimization/111770] " rguenth at gcc dot gnu.org
2024-02-21 17:14 ` acoplan at gcc dot gnu.org
2024-02-22  8:10 ` rguenth at gcc dot gnu.org
2024-02-22 11:10 ` acoplan at gcc dot gnu.org
2024-02-22 13:16 ` rguenth at gcc dot gnu.org [this message]
2024-02-22 17:11 ` jsm28 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-111770-4-3u8okSGrRM@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).