public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/112636] New: ICE on valid code at -O1 (but not at -O{0,s,2,3}) with "-ftree-vectorize": in adjust_loop_info_after_peeling, at tree-ssa-loop-ivcanon.cc:1069
@ 2023-11-20 11:30 zhendong.su at inf dot ethz.ch
2023-11-20 12:56 ` [Bug tree-optimization/112636] [14 Regression] " rguenth at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: zhendong.su at inf dot ethz.ch @ 2023-11-20 11:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112636
Bug ID: 112636
Summary: ICE on valid code at -O1 (but not at -O{0,s,2,3}) with
"-ftree-vectorize": in adjust_loop_info_after_peeling,
at tree-ssa-loop-ivcanon.cc:1069
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: zhendong.su at inf dot ethz.ch
Target Milestone: ---
This appears to be a recent regression as it does not seem to reproduce with
13.2.
Compiler Explorer: https://godbolt.org/z/WYsasWefh
[526] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20231119 (experimental) (GCC)
[527] %
[527] % gcctk -O1 small.c; ./a.out
[528] %
[528] % gcctk -O1 -ftree-vectorize small.c
during GIMPLE pass: ch_vect
small.c: In function ‘main’:
small.c:3:5: internal compiler error: in adjust_loop_info_after_peeling, at
tree-ssa-loop-ivcanon.cc:1069
3 | int main() {
| ^~~~
0x87ac95 adjust_loop_info_after_peeling(loop*, int, bool)
../../gcc-trunk/gcc/tree-ssa-loop-ivcanon.cc:1069
0x129b514 copy_headers
../../gcc-trunk/gcc/tree-ssa-loop-ch.cc:1108
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.
[529] %
[529] % cat small.c
int a[1], b;
unsigned c;
int main() {
while (b) {
if (a[c])
break;
c--;
}
return 0;
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/112636] [14 Regression] ICE on valid code at -O1 (but not at -O{0,s,2,3}) with "-ftree-vectorize": in adjust_loop_info_after_peeling, at tree-ssa-loop-ivcanon.cc:1069
2023-11-20 11:30 [Bug tree-optimization/112636] New: ICE on valid code at -O1 (but not at -O{0,s,2,3}) with "-ftree-vectorize": in adjust_loop_info_after_peeling, at tree-ssa-loop-ivcanon.cc:1069 zhendong.su at inf dot ethz.ch
@ 2023-11-20 12:56 ` rguenth at gcc dot gnu.org
2024-01-11 12:38 ` rguenth at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-11-20 12:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112636
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |14.0
CC| |hubicka at gcc dot gnu.org
Keywords| |ice-on-valid-code,
| |missed-optimization
Priority|P3 |P1
Version|unknown |14.0
Status|UNCONFIRMED |NEW
Last reconfirmed| |2023-11-20
Summary|ICE on valid code at -O1 |[14 Regression] ICE on
|(but not at -O{0,s,2,3}) |valid code at -O1 (but not
|with "-ftree-vectorize": in |at -O{0,s,2,3}) with
|adjust_loop_info_after_peel |"-ftree-vectorize": in
|ing, at |adjust_loop_info_after_peel
|tree-ssa-loop-ivcanon.cc:10 |ing, at
|69 |tree-ssa-loop-ivcanon.cc:10
| |69
Ever confirmed|0 |1
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.
if (wi::leu_p (npeel, loop->nb_iterations_upper_bound))
loop->nb_iterations_upper_bound -= npeel;
else
{
/* Peeling maximal number of iterations or more
makes no sense and is a bug.
We should peel completely. */
gcc_unreachable ();
so we're asking to adjust for peeling of 1 iteration with an upper bound
of iterations of zero. We derive this limit from the array size of a[].
Caused by Honzas loop header copying changes.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/112636] [14 Regression] ICE on valid code at -O1 (but not at -O{0,s,2,3}) with "-ftree-vectorize": in adjust_loop_info_after_peeling, at tree-ssa-loop-ivcanon.cc:1069
2023-11-20 11:30 [Bug tree-optimization/112636] New: ICE on valid code at -O1 (but not at -O{0,s,2,3}) with "-ftree-vectorize": in adjust_loop_info_after_peeling, at tree-ssa-loop-ivcanon.cc:1069 zhendong.su at inf dot ethz.ch
2023-11-20 12:56 ` [Bug tree-optimization/112636] [14 Regression] " rguenth at gcc dot gnu.org
@ 2024-01-11 12:38 ` rguenth at gcc dot gnu.org
2024-01-11 13:50 ` cvs-commit at gcc dot gnu.org
2024-01-11 13:50 ` rguenth at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-01-11 12:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112636
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org
Status|NEW |ASSIGNED
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
The issue is that should_duplicate_loop_header_p we call after
basic_block header = loop->header;
if (!get_max_loop_iterations_int (loop))
{
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "Loop %d never loops.\n", loop->num);
scale_loop_profile (loop, profile_probability::always (), 0);
loops_to_unloop.safe_push (loop);
loops_to_unloop_nunroll.safe_push (0);
continue;
ends up calling estimate_numbers_of_iterations () only then actually
updating the upper bound we check above. It does so hidden via
#0 estimate_numbers_of_iterations (loop=0x7ffff700e4b0)
at /space/rguenther/src/gcc/gcc/tree-ssa-loop-niter.cc:4806
#1 0x00000000019434ef in loop_exits_before_overflow (
base=<ssa_name 0x7ffff71e5120 8>, step=<integer_cst 0x7ffff702d180>,
at_stmt=<gimple_phi 0x7ffff71bb700>, loop=0x7ffff700e4b0)
at /space/rguenther/src/gcc/gcc/tree-ssa-loop-niter.cc:5259
#2 0x00000000019440b0 in scev_probably_wraps_p (var=<tree 0x0>,
base=<ssa_name 0x7ffff71e5120 8>, step=<integer_cst 0x7ffff702d180>,
at_stmt=<gimple_phi 0x7ffff71bb700>, loop=0x7ffff700e4b0,
use_overflow_semantics=true)
at /space/rguenther/src/gcc/gcc/tree-ssa-loop-niter.cc:5511
#3 0x0000000001bb97ea in get_scev_info (r=...,
name=<ssa_name 0x7ffff7016f78 4>, stmt=<gimple_phi 0x7ffff71bb700>,
l=0x7ffff700e4b0, init=@0x7fffffffa898: <ssa_name 0x7ffff71e5120 8>,
step=@0x7fffffffa890: <integer_cst 0x7ffff702d180>,
dir=@0x7fffffffa88c: EV_DIR_DECREASES)
at /space/rguenther/src/gcc/gcc/vr-values.cc:204
#4 0x0000000001bb9d6d in range_of_var_in_loop (v=...,
name=<ssa_name 0x7ffff7016f78 4>, l=0x7ffff700e4b0,
stmt=<gimple_phi 0x7ffff71bb700>, query=0x4961550)
at /space/rguenther/src/gcc/gcc/vr-values.cc:271
#5 0x0000000002edf824 in fold_using_range::range_of_ssa_name_with_loop_info (
this=0x7fffffffb46f, r=..., name=<ssa_name 0x7ffff7016f78 4>,
...
#22 0x00000000018f3f77 in should_duplicate_loop_header_p (
header=<basic_block 0x7ffff71be6c0 (4)>, loop=0x7ffff700e4b0,
ranger=0x4961550, limit=0x7fffffffd88c, invariant_exits=0x47e60f0,
static_exits=0x4961040)
at /space/rguenther/src/gcc/gcc/tree-ssa-loop-ch.cc:251
#23 0x00000000018f59d7 in (anonymous namespace)::ch_base::copy_headers (
this=0x47f2a30, fun=0x7ffff71e2000)
at /space/rguenther/src/gcc/gcc/tree-ssa-loop-ch.cc:831
The best is to analyze niters for the loop we try to process.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/112636] [14 Regression] ICE on valid code at -O1 (but not at -O{0,s,2,3}) with "-ftree-vectorize": in adjust_loop_info_after_peeling, at tree-ssa-loop-ivcanon.cc:1069
2023-11-20 11:30 [Bug tree-optimization/112636] New: ICE on valid code at -O1 (but not at -O{0,s,2,3}) with "-ftree-vectorize": in adjust_loop_info_after_peeling, at tree-ssa-loop-ivcanon.cc:1069 zhendong.su at inf dot ethz.ch
2023-11-20 12:56 ` [Bug tree-optimization/112636] [14 Regression] " rguenth at gcc dot gnu.org
2024-01-11 12:38 ` rguenth at gcc dot gnu.org
@ 2024-01-11 13:50 ` cvs-commit at gcc dot gnu.org
2024-01-11 13:50 ` rguenth at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-11 13:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112636
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:05e8ef2a05b477589cae25af3311bad0f68a90fe
commit r14-7138-g05e8ef2a05b477589cae25af3311bad0f68a90fe
Author: Richard Biener <rguenther@suse.de>
Date: Thu Jan 11 13:35:51 2024 +0100
tree-optimization/112636 - estimate niters before header copying
The following avoids a mismatch between an early query for maximum
number of iterations of a loop and a late one when through ranger
we'd get iterations estimated. Instead make sure we compute niters
before querying the iteration bound.
PR tree-optimization/112636
* tree-ssa-loop-ch.cc (ch_base::copy_headers): Call
estimate_numbers_of_iterations before querying
get_max_loop_iterations_int.
(pass_ch::execute): Initialize SCEV and loops appropriately.
* gcc.dg/pr112636.c: New testcase.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/112636] [14 Regression] ICE on valid code at -O1 (but not at -O{0,s,2,3}) with "-ftree-vectorize": in adjust_loop_info_after_peeling, at tree-ssa-loop-ivcanon.cc:1069
2023-11-20 11:30 [Bug tree-optimization/112636] New: ICE on valid code at -O1 (but not at -O{0,s,2,3}) with "-ftree-vectorize": in adjust_loop_info_after_peeling, at tree-ssa-loop-ivcanon.cc:1069 zhendong.su at inf dot ethz.ch
` (2 preceding siblings ...)
2024-01-11 13:50 ` cvs-commit at gcc dot gnu.org
@ 2024-01-11 13:50 ` rguenth at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-01-11 13:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112636
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-01-11 13:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-20 11:30 [Bug tree-optimization/112636] New: ICE on valid code at -O1 (but not at -O{0,s,2,3}) with "-ftree-vectorize": in adjust_loop_info_after_peeling, at tree-ssa-loop-ivcanon.cc:1069 zhendong.su at inf dot ethz.ch
2023-11-20 12:56 ` [Bug tree-optimization/112636] [14 Regression] " rguenth at gcc dot gnu.org
2024-01-11 12:38 ` rguenth at gcc dot gnu.org
2024-01-11 13:50 ` cvs-commit at gcc dot gnu.org
2024-01-11 13:50 ` rguenth at gcc dot gnu.org
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).