public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "aldyh at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/108647] [13 Regression] ICE in upper_bound, at value-range.h:950 with -O3 since r13-2974-g67166c9ec35d58ef
Date: Fri, 03 Feb 2023 12:46:32 +0000	[thread overview]
Message-ID: <bug-108647-4-l790h48lOO@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-108647-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #5 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
> Perhaps just adding if (op2.undefined_p ()) return false; above most of the
> switch (get_bool_state (r, lhs, type)) lines (in methods that refer to op2;
> and similarly for op1) for the comparison operators.

This feels like the right approach.  We also do something similar in some of
the binary operators.  For example, plus/minus_expr do:

  if (lhs.undefined_p ())
    return false;

For this testcase we have:

[0,0] = UNDEFINED < op2

I don't think we can determine anything for op2 in this situation, so the right
thing would be to return false, which amounts to returning VARYING.

The binary operators would also have to handle operators of undefined, but
those seem to all have gates on singleton_p() or go through the fold_range()
routine for the inverse operation, so they'd be handled correctly.

So yeah, it looks like just handling the op[12]_range operators above the
get_bool_state would do the trick.

Hmmm, it seems like there are 2 operators that have possible problematic
handling of op2.undefined_p():

1. operator_cast::op1_range (irange &r, tree type,

   The assert looks at the op2 type.  That will ICE with an UNDEFINED.

   The truncating_cast_p path will also look at op2's type blindly.

2. operator_bitwise_xor::op1_range

  Imagine: [0,0] = x ^ UNDEFINED

  op1_range won't ICE, but it will do:

        case BRS_FALSE:
          r = op2;

  I don't think we know anything about x in this case.  Though if, op2 is
UNDEFINED, I guess it
  wouldn't hurt to assume op1 is also UNDEFINED.

   Also earlier in the function, for:

     UNDEFINED = x ^ op2

   will return x = UNDEFINED for any op2.  

So at least #1 would also have to be handled because it could ICE.

Also, range-op-float.cc needs the same treatment prior all the get_bool_state
calls.

As you mention, another alternative would be to always call
empty_range_varying, as we're doing for abs::op[12]_range:

  if (empty_range_varying (r, type, lhs, op2))
    return true;

Thoughts?  Andrew?

Hmmm, I wonder why we haven't tripped over this scenario in past releases (LHS
being defined, but op2 being UNDEFINED).

  parent reply	other threads:[~2023-02-03 12:46 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-02 21:21 [Bug tree-optimization/108647] New: [13 Regression] ICE in upper_bound, at value-range.h:950 with -O3 vsevolod.livinskiy at gmail dot com
2023-02-03  1:45 ` [Bug tree-optimization/108647] " pinskia at gcc dot gnu.org
2023-02-03  8:04 ` rguenth at gcc dot gnu.org
2023-02-03  9:21 ` [Bug tree-optimization/108647] [13 Regression] ICE in upper_bound, at value-range.h:950 with -O3 since r13-2974-g67166c9ec35d58ef marxin at gcc dot gnu.org
2023-02-03  9:29 ` jakub at gcc dot gnu.org
2023-02-03  9:54 ` jakub at gcc dot gnu.org
2023-02-03 12:46 ` aldyh at gcc dot gnu.org [this message]
2023-02-03 14:54 ` amacleod at redhat dot com
2023-02-03 15:11 ` jakub at gcc dot gnu.org
2023-02-03 15:15 ` jakub at gcc dot gnu.org
2023-02-03 15:20 ` amacleod at redhat dot com
2023-02-03 15:23 ` jakub at gcc dot gnu.org
2023-02-03 15:28 ` amacleod at redhat dot com
2023-02-03 16:16 ` aldyh at gcc dot gnu.org
2023-02-03 16:31 ` aldyh at gcc dot gnu.org
2023-02-03 16:33 ` jakub at gcc dot gnu.org
2023-02-03 16:35 ` aldyh at gcc dot gnu.org
2023-02-03 20:31 ` cvs-commit at gcc dot gnu.org
2023-02-03 20:39 ` cvs-commit at gcc dot gnu.org
2023-02-03 20:43 ` jakub at gcc dot gnu.org
2023-02-04  1:35 ` raj.khem at gmail dot com
2023-02-04  4:28 ` jakub at gcc dot gnu.org
2023-02-04  5:25 ` jakub at gcc dot gnu.org
2023-02-04  7:26 ` raj.khem at gmail dot com

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-108647-4-l790h48lOO@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).