From: Aldy Hernandez Date: Tue, 13 Oct 2020 07:05:23 +0000 (-0400) Subject: Do not call range_of_ssa_name_with_loop_info with the loop tree root. X-Git-Tag: basepoints/gcc-12~4377 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a121715bcab6e8980768d142b9781c45821130ac;p=thirdparty%2Fgcc.git Do not call range_of_ssa_name_with_loop_info with the loop tree root. gcc/ChangeLog: PR tree-optimization/97396 * gimple-range.cc (gimple_ranger::range_of_phi): Do not call range_of_ssa_name_with_loop_info with the loop tree root. gcc/testsuite/ChangeLog: * gcc.dg/pr97396.c: New test. --- diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc index 2ca86ed0e4c7..999d631c5ee9 100644 --- a/gcc/gimple-range.cc +++ b/gcc/gimple-range.cc @@ -490,7 +490,7 @@ gimple_ranger::range_of_phi (irange &r, gphi *phi) { value_range loop_range; class loop *l = loop_containing_stmt (phi); - if (l) + if (l && loop_outer (l)) { range_of_ssa_name_with_loop_info (loop_range, phi_def, l, phi); if (!loop_range.varying_p ()) diff --git a/gcc/testsuite/gcc.dg/pr97396.c b/gcc/testsuite/gcc.dg/pr97396.c new file mode 100644 index 000000000000..d992c11f2387 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr97396.c @@ -0,0 +1,23 @@ +// { dg-do compile } +// { dg-options "-O1 -ftree-vrp" } +// { dg-additional-options "-m32" { target { i?86-*-* x86_64-*-* } } } + +unsigned int +po (char *os, unsigned int al) +{ + for (;;) + { + int qx = 0; + + while (al < 1) + { + char *cw; + + cw = os + qx; + if (cw) + return al + qx; + + qx += sizeof *cw; + } + } +}