gnu/gcc/bb6660183276d4b5b450beb2303e8b6e6aaa2f08 ranger: walk a constant array's initializer by index
A load from a constant array at an unknown index unions every element
of its initializer, and adds zero if the initializer has fewer
elements than the array. We currently do this by counting, ignoring
position. My next patch will need to know where the missing elements
are, so this patch changes the approach to a walk instead of a count.
We cap initializers at 32 elements by default (--param
vrp-cstload-limit), so there's no penalty for doing the walk. For
that matter, the whole patch series is a wash in compile time
performance.
Tested on ppc64le Linux, including Ada for the swapped ranges test.
No assembly changes over a corpus of .ii files from a stage1
bootstrap.
gcc/ChangeLog:
* gimple-range-fold.cc
(ctor_ref_range::accumulate_range_from_array_ref): Walk the
initializer by index to find the elements it leaves out.
gcc/testsuite/ChangeLog:
* g++.dg/tree-ssa/vrp-from-cst-agg-1.C: New test.
* gcc.dg/tree-ssa/vrp-from-cst-agg-9.c: New test.
* gnat.dg/opt111.adb: New test.
4 files changed