public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/112509] New: GCC: 14: internal compiler error: in verify_range, at value-range.cc:1132
@ 2023-11-13 11:59 141242068 at smail dot nju.edu.cn
2023-11-13 12:26 ` [Bug tree-optimization/112509] " rguenth at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: 141242068 at smail dot nju.edu.cn @ 2023-11-13 11:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112509
Bug ID: 112509
Summary: GCC: 14: internal compiler error: in verify_range, at
value-range.cc:1132
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: 141242068 at smail dot nju.edu.cn
Target Milestone: ---
Compiler Explorer: https://gcc.godbolt.org/z/151vEnafj
When compiling this program with `gcc-14 -O2 -fno-tree-vrp -fno-tree-fre
-fno-tree-forwprop`, gcc crashes:
```
struct S {
unsigned j : 3;
};
int k, l, m_1 = {0};
void f(int l, struct S x) {
unsigned int k_1;
while (m_1 % 8) switch (x.j) {
case 1:
case 3:
case 4:
case 6:
case 2:
case 5: l = m_1;
case 7:
case 0: k_1 = 0;
default: break;
}
}
void foo(struct S x) { f(l, x); }
```
The crash output:
```
during GIMPLE pass: dom
<source>: In function 'f':
<source>:5:6: internal compiler error: in verify_range, at value-range.cc:1132
5 | void f(int l, struct S x) {
| ^
0x238b06e internal_error(char const*, ...)
???:0
0xa1125c fancy_abort(char const*, int, char const*)
???:0
0x148ea37 irange::set(tree_node*, generic_wide_int<wide_int_storage> const&,
generic_wide_int<wide_int_storage> const&, value_range_kind)
???:0
0x144ca1f find_case_label_range(gswitch*, irange const*)
???:0
0x139e1ef hybrid_jt_simplifier::simplify(gimple*, gimple*, basic_block_def*,
jt_state*)
???:0
0x139d525 jump_threader::simplify_control_stmt_condition(edge_def*, gimple*)
???:0
0x139db5a jump_threader::thread_through_normal_block(vec<jump_thread_edge*,
va_heap, vl_ptr>*, edge_def*, bitmap_head*)
???:0
0x139fa66 jump_threader::thread_across_edge(edge_def*)
???:0
0x139fc5a jump_threader::thread_outgoing_edges(basic_block_def*)
???:0
0x126f828 dom_opt_dom_walker::after_dom_children(basic_block_def*)
???:0
0x1ed3f2f dom_walker::walk(basic_block_def*)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1
```
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/112509] GCC: 14: internal compiler error: in verify_range, at value-range.cc:1132
2023-11-13 11:59 [Bug c/112509] New: GCC: 14: internal compiler error: in verify_range, at value-range.cc:1132 141242068 at smail dot nju.edu.cn
@ 2023-11-13 12:26 ` rguenth at gcc dot gnu.org
2023-11-13 14:46 ` amacleod at redhat dot com
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-11-13 12:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112509
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2023-11-13
Status|UNCONFIRMED |NEW
Keywords| |ice-checking,
| |ice-on-valid-code
Ever confirmed|0 |1
Component|c |tree-optimization
CC| |amacleod at redhat dot com
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed. Somehow lb and ub are "swapped".
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/112509] GCC: 14: internal compiler error: in verify_range, at value-range.cc:1132
2023-11-13 11:59 [Bug c/112509] New: GCC: 14: internal compiler error: in verify_range, at value-range.cc:1132 141242068 at smail dot nju.edu.cn
2023-11-13 12:26 ` [Bug tree-optimization/112509] " rguenth at gcc dot gnu.org
@ 2023-11-13 14:46 ` amacleod at redhat dot com
2023-11-14 6:03 ` [Bug tree-optimization/112509] [14 Regression] " pinskia at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: amacleod at redhat dot com @ 2023-11-13 14:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112509
--- Comment #2 from Andrew Macleod <amacleod at redhat dot com> ---
the original switch is an unsigned value with precision of 3 bits, so 0..7 just
fits.
It gets translated to an int index during gimplification, but the case labels
are still precision 3 values.
find_case_label_ranges in tree-vrp.cc does the following:
tree label = gimple_switch_label (switch_stmt, i);
tree case_high
= CASE_HIGH (label) ? CASE_HIGH (label) : CASE_LOW (label);
wide_int wlow = wi::to_wide (CASE_LOW (label));
wide_int whigh = wi::to_wide (case_high);
int_range_max label_range (type,
wide_int::from (wlow, prec, sign),
wide_int::from (whigh, prec, sign));
CASE_HIGH is indeed 6, but when we to the to_wide call, it is sign extended to
produce:
(gdb) p whigh.dump ()
[0xfffffffffffffffe], precision = 3
but then when we do wide_int::from() in the signed int precision 32 of the new
switch type, we get -2 for the high value.
Whats suppose to happen here? seems odd to me that the case labels are a
different precision than the switch itself.. but then we would also lose the
fact that there is only 3 bits of precision in the switch.
Should the low and high values be cast from the original case precision/type to
the new perhaps?
something like this seems to work:
tree
find_case_label_range (gswitch *switch_stmt, const irange *range_of_op)
@@ -900,9 +901,9 @@ find_case_label_range (gswitch *switch_stmt, const irange
*range_of_op)
= CASE_HIGH (label) ? CASE_HIGH (label) : CASE_LOW (label);
wide_int wlow = wi::to_wide (CASE_LOW (label));
wide_int whigh = wi::to_wide (case_high);
- int_range_max label_range (type,
- wide_int::from (wlow, prec, sign),
- wide_int::from (whigh, prec, sign));
+ int_range_max label_range (TREE_TYPE (case_high), wlow, whigh);
+ range_cast (label_range, type);
+ label_range.dump(stderr);
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/112509] [14 Regression] internal compiler error: in verify_range, at value-range.cc:1132
2023-11-13 11:59 [Bug c/112509] New: GCC: 14: internal compiler error: in verify_range, at value-range.cc:1132 141242068 at smail dot nju.edu.cn
2023-11-13 12:26 ` [Bug tree-optimization/112509] " rguenth at gcc dot gnu.org
2023-11-13 14:46 ` amacleod at redhat dot com
@ 2023-11-14 6:03 ` pinskia at gcc dot gnu.org
2023-11-14 15:33 ` cvs-commit at gcc dot gnu.org
2023-11-14 15:34 ` amacleod at redhat dot com
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-14 6:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112509
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |14.0
Summary|GCC: 14: internal compiler |[14 Regression] internal
|error: in verify_range, at |compiler error: in
|value-range.cc:1132 |verify_range, at
| |value-range.cc:1132
Keywords| |needs-bisection
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This looks to be a GCC 14 regression.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/112509] [14 Regression] internal compiler error: in verify_range, at value-range.cc:1132
2023-11-13 11:59 [Bug c/112509] New: GCC: 14: internal compiler error: in verify_range, at value-range.cc:1132 141242068 at smail dot nju.edu.cn
` (2 preceding siblings ...)
2023-11-14 6:03 ` [Bug tree-optimization/112509] [14 Regression] " pinskia at gcc dot gnu.org
@ 2023-11-14 15:33 ` cvs-commit at gcc dot gnu.org
2023-11-14 15:34 ` amacleod at redhat dot com
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-11-14 15:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112509
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Andrew Macleod <amacleod@gcc.gnu.org>:
https://gcc.gnu.org/g:8f331be42991aa4d58ac770faf993accfcce882b
commit r14-5449-g8f331be42991aa4d58ac770faf993accfcce882b
Author: Andrew MacLeod <amacleod@redhat.com>
Date: Mon Nov 13 09:58:10 2023 -0500
Use case label type to create case range.
Create a range from the label type, and cast it to the required type.
PR tree-optimization/112509
gcc/
* tree-vrp.cc (find_case_label_range): Create range from case
labels.
gcc/testsuite/
* gcc.dg/pr112509.c: New.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/112509] [14 Regression] internal compiler error: in verify_range, at value-range.cc:1132
2023-11-13 11:59 [Bug c/112509] New: GCC: 14: internal compiler error: in verify_range, at value-range.cc:1132 141242068 at smail dot nju.edu.cn
` (3 preceding siblings ...)
2023-11-14 15:33 ` cvs-commit at gcc dot gnu.org
@ 2023-11-14 15:34 ` amacleod at redhat dot com
4 siblings, 0 replies; 6+ messages in thread
From: amacleod at redhat dot com @ 2023-11-14 15:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112509
Andrew Macleod <amacleod at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #5 from Andrew Macleod <amacleod at redhat dot com> ---
fixed.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-11-14 15:34 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-13 11:59 [Bug c/112509] New: GCC: 14: internal compiler error: in verify_range, at value-range.cc:1132 141242068 at smail dot nju.edu.cn
2023-11-13 12:26 ` [Bug tree-optimization/112509] " rguenth at gcc dot gnu.org
2023-11-13 14:46 ` amacleod at redhat dot com
2023-11-14 6:03 ` [Bug tree-optimization/112509] [14 Regression] " pinskia at gcc dot gnu.org
2023-11-14 15:33 ` cvs-commit at gcc dot gnu.org
2023-11-14 15:34 ` amacleod at redhat dot com
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).