aboutsummaryrefslogtreecommitdiff
path: root/libphobos/src
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2025-01-13 13:24:06 +0100
committerRichard Biener <rguenth@gcc.gnu.org>2025-01-17 08:38:51 +0100
commit44d21551362f9076617200595f49d4260d1f40a9 (patch)
treefa7223819bd05e178c0a5446490027ead8f585e2 /libphobos/src
parentc6f9f53d6eb5a2568d231ffa56fbec3e2e4c626d (diff)
downloadgcc-44d21551362f9076617200595f49d4260d1f40a9.zip
gcc-44d21551362f9076617200595f49d4260d1f40a9.tar.gz
gcc-44d21551362f9076617200595f49d4260d1f40a9.tar.bz2
tree-optimization/92539 - missed optimization leads to bogus -Warray-bounds
The following makes niter analysis recognize a loop with an exit condition scanning over a STRING_CST. This is done via enhancing the force evaluation code rather than recognizing for example strlen (s) as number of iterations because it allows to handle some more cases. STRING_CSTs are easy to handle since nothing can write to them, also processing those should be cheap. I've refrained from handling anything besides char8_t. Note to avoid the -Warray-bound dianostic we have to either early unroll the loop (there's no final value replacement done, there's a PR for doing this as part of CD-DCE when possibly eliding a loop), or create a canonical IV so we can DCE the loads. The latter is what the patch does, also avoiding to repeatedly force-evaluate niters. This also makes final value replacement work again since now ivcanon is after it. There are some testsuite adjustments needed, in particular we now unroll some loops early, causing messages to appear in different passes but also vectorization to now no longer happening on outer loops. The changes mitigate that. PR tree-optimization/92539 * tree-ssa-loop-ivcanon.cc (tree_unroll_loops_completely_1): Also try force-evaluation if ivcanon did not yet run. (canonicalize_loop_induction_variables): When niter was computed constant by force evaluation add a canonical IV if we didn't unroll. * tree-ssa-loop-niter.cc (loop_niter_by_eval): When we don't find a proper PHI try if the exit condition scans over a STRING_CST and simulate that. * g++.dg/warn/Warray-bounds-pr92539.C: New testcase. * gcc.dg/tree-ssa/sccp-16.c: New testcase. * g++.dg/vect/pr87621.cc: Use larger power to avoid inner loop unrolling. * gcc.dg/vect/pr89440.c: Use larger loop bound to avoid inner loop unrolling. * gcc.dg/pr77975.c: Scan cunrolli dump and adjust.
Diffstat (limited to 'libphobos/src')
0 files changed, 0 insertions, 0 deletions