[clang] [llvm] [openmp] [CLANG][OpenMP] Restore loop variable values after transformation directives (PR #214717)
Zahira Ammarguellat via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 9 13:56:54 PDT 2026
zahiraam wrote:
> Check these tests:
>
> ```
> #include <stdio.h>
> #include <stdlib.h>
> int main() {
> int i, j, k;
> int count = 0;
> #pragma omp fuse looprange(1, 2)
> {
> for (i = 0; i < 10; i++)
> ;
> for (j = 0; j < 15; j++)
> ;
> // Reads i: must observe the loop-exit value 10, not the value left by
> // the last fused iteration (9).
> for (k = 0; k < i; k++)
> count++;
> }
> printf("count=%d i=%d j=%d k=%d\n", count, i, j, k);
> return EXIT_SUCCESS;
> }
> ```
>
> ```
> #include <stdio.h>
> #include <stdlib.h>
> int main() {
> int i, j, l;
> #pragma omp fuse
> {
> #pragma omp fuse
> {
> for (i = 0; i < 10; i++)
> ;
> for (j = 0; j < 20; j++)
> ;
> }
> for (l = 0; l < 5; l++)
> ;
> }
> printf("i=%d j=%d l=%d\n", i, j, l);
> return EXIT_SUCCESS;
> }
> ```
>
> ```
>
> #include <stdio.h>
> #include <stdlib.h>
> int main() {
> int i, j, k, l;
> #pragma omp fuse looprange(2, 2)
> {
> #pragma omp fuse looprange(2, 2)
> {
> for (i = 0; i < 8; i++)
> ;
> for (j = 0; j < 16; j++)
> ;
> for (k = 0; k < 32; k++)
> ;
> }
> for (l = 0; l < 4; l++)
> ;
> }
> printf("i=%d j=%d k=%d l=%d\n", i, j, k, l);
> return EXIT_SUCCESS;
> }
> ```
With the new commit, these tests are generating the correct values.
https://github.com/llvm/llvm-project/pull/214717
More information about the cfe-commits
mailing list