openmp: Adjust outer bounds of non-rect loops
In loops like:
#pragma omp parallel for collapse(2)
for (i = -4; i < 8; i++)
for (j = 3 * i; j > 2 * i; j--)
for some outer loop iterations there are no inner loop iterations at all,
the condition is false. In order to use Summæ Potestate to count number
of iterations or to transform the logical iteration number to actual
iterator values using quadratic non-equation root discovery the outer
iterator range needs to be adjusted, such that the inner loop has at least
one iteration for each of the outer loop iterator value in the reduced
range. Sometimes this adjustment is done at the start of the range,
at other times at the end.
This patch implements it during the compile time number of loop computation
(if all expressions are compile time constants).
2020-07-14 Jakub Jelinek <jakub@redhat.com>
* omp-general.h (struct omp_for_data): Add adjn1 member.
* omp-general.c (omp_extract_for_data): For non-rect loop, punt on
count computing if n1, n2 or step are not INTEGER_CST earlier.
Narrow the outer iterator range if needed so that non-rect loop
has at least one iteration for each outer range iteration. Compute
adjn1.
* omp-expand.c (expand_omp_for_init_vars): Use adjn1 if non-NULL
instead of the outer loop's n1.
* testsuite/libgomp.c/loop-21.c: New test.