From a121715bcab6e8980768d142b9781c45821130ac Mon Sep 17 00:00:00 2001 From: Aldy Hernandez Date: Tue, 13 Oct 2020 03:05:23 -0400 Subject: [PATCH] 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. --- gcc/gimple-range.cc | 2 +- gcc/testsuite/gcc.dg/pr97396.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/pr97396.c diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc index 2ca86ed0e4c..999d631c5ee 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 00000000000..d992c11f238 --- /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; + } + } +} -- 2.30.2