[Bug middle-end/121453] [OpenMP] 'omp simd' with 'collapse' – variable '.count' uninitialized, but used as 'if (.iter.14 == .count.15)'
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Sep 24 15:45:00 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121453
--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-15 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:cb24799a21dae86162e418c6baa44f4e32b8e7cc
commit r15-10359-gcb24799a21dae86162e418c6baa44f4e32b8e7cc
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue Aug 26 00:28:10 2025 +0200
omp-expand: Initialize fd->loop.n2 if needed for the zero iter case
[PR121453]
When expand_omp_for_init_counts is called from expand_omp_for_generic,
zero_iter1_bb is NULL and the code always creates a new bb in which it
clears fd->loop.n2 var (if it is a var), because it can dominate code
with lastprivate guards that use the var.
When called from other places, zero_iter1_bb is non-NULL and so we don't
insert the clearing (and can't, because the same bb is used also for the
non-zero iterations exit and in that case we need to preserve the iteration
count). Clearing is also not necessary when e.g. outermost collapsed
loop has constant non-zero number of iterations, in that case we initialize
the
var to something already earlier. The following patch makes sure to clear
it if it hasn't been initialized yet before the first check for zero
iterations.
2025-08-26 Jakub Jelinek <jakub@redhat.com>
PR middle-end/121453
* omp-expand.cc (expand_omp_for_init_counts): Clear fd->loop.n2
before first zero count check if zero_iter1_bb is non-NULL upon
entry and fd->loop.n2 has not been written yet.
* gcc.dg/gomp/pr121453.c: New test.
(cherry picked from commit 948f20cc520e50968f8759b173096358dcbba3de)
More information about the Gcc-bugs
mailing list