public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "amacleod at redhat dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/105820] [13 Regression] ICE in invert, at value-range.cc:1971
Date: Thu, 16 Jun 2022 14:00:13 +0000	[thread overview]
Message-ID: <bug-105820-4-msWOKEXPIl@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-105820-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #4 from Andrew Macleod <amacleod at redhat dot com> ---
Well, thats not really the problem here. We are casting
  [irange] gimple_code [2, 2]
to a gimple_code, and getting:
  [irange] gimple_code VARYING

Couple of issues.. one, we shouldnt bother casting anything if the types are
already the same...  but still.. the result is incorrect.

Tracing it down, it looks like during the casting process, we call:
operator_cast::inside_domain_p so see if a min == 2, max == 2, is inside the
range of    [irange] gimple_code VARYING.

THe routine returns false because with strict enum on, we get the min and max
of the domain from:

  wide_int domain_min = wi::to_wide (vrp_val_min (range.type ()));
  wide_int domain_max = wi::to_wide (vrp_val_max (range.type ()));,  which
boils 

down to TYPE_MIN_VALUE (gimple_code) and TYPE_MAX_VALUE (gimple_code)

p range.type ()
$29 = (tree_node *) 0x7fffe9f77c78

(gdb) p print_generic_expr (stderr, $29, 0)
gimple_code

(gdb) p print_generic_expr (stderr, $29->type_non_common.minval, 0)
0

(gdb) p print_generic_expr (stderr, $29->type_non_common.maxval, 0)
1 

So the min value for the enum is set correctly to 0, but the max is set to 1... 
thus the routine determines that [2, 2] is not within the range of [0, 1] and
returns varying..

It seems like the max value for the enum is not being set correctly?

If I check right at the point of the failure:
(gdb) frame 1

#1  0x0000000001c9c4fe in irange::invert (this=0x7fffffff1570) at
/home/gcc/master/gcc/gcc/value-range.cc:2185
2185      gcc_checking_assert (!undefined_p () && !varying_p ());
(gdb) p type()
$42 = (tree_node *) 0x7fffe9f77c78
(gdb) p print_generic_expr (stderr, type(), 0)
gimple_code
(gdb) p print_generic_expr (stderr, type()->type_non_common.maxval, 0)
1

  parent reply	other threads:[~2022-06-16 14:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-02 11:10 [Bug tree-optimization/105820] New: " asolokha at gmx dot com
2022-06-02 12:18 ` [Bug tree-optimization/105820] " rguenth at gcc dot gnu.org
2022-06-02 13:05 ` amacleod at redhat dot com
2022-06-03  5:30 ` aldyh at gcc dot gnu.org
2022-06-16 14:00 ` amacleod at redhat dot com [this message]
2022-10-17 11:24 ` asolokha at gmx dot com
2022-10-17 12:14 ` marxin at gcc dot gnu.org
2022-10-17 12:38 ` asolokha at gmx dot com
2022-10-17 12:42 ` marxin at gcc dot gnu.org
2022-10-17 13:41 ` cvs-commit 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-105820-4-msWOKEXPIl@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).