Skip to content

[LoopVectorize] Fails on OpenMP SIMD Prefix Sum #135576

Open
@orpheezt

Description

@orpheezt

On clang 19.1.7

void prefix_scan_omp_simd(uint64_t n, const float *const __restrict src,
                          float *const __restrict dst, const double init) {
  auto acc = init;
#pragma omp simd reduction(inscan, + : acc)
  for (uint64_t i = 0; i < n; ++i) {
    acc += src[i];
#pragma omp scan inclusive(acc)
    dst[i] = acc;
  }
}

The following code is emitting the warning

warning: loop not vectorized: the optimizer was unable to perform the requested transformation; the transformation might be disabled or specified as part of an unsupported transformation ordering [-Wpass-failed=transform-warning]
   15 | #pragma omp simd reduction(inscan, + : acc)
      | ^
1 warning generated.

While on gcc it suceeds.

Activity

llvmbot

llvmbot commented on Apr 29, 2025

@llvmbot
Member

@llvm/issue-subscribers-openmp

Author: Isaac David (orpheezt)

On `clang 19.1.7`
void prefix_scan_omp_simd(uint64_t n, const float *const __restrict src,
                          float *const __restrict dst, const double init) {
  auto acc = init;
#pragma omp simd reduction(inscan, + : acc)
  for (uint64_t i = 0; i &lt; n; ++i) {
    acc += src[i];
#pragma omp scan inclusive(acc)
    dst[i] = acc;
  }
}

The following code is emitting the warning

warning: loop not vectorized: the optimizer was unable to perform the requested transformation; the transformation might be disabled or specified as part of an unsupported transformation ordering [-Wpass-failed=transform-warning]
   15 | #pragma omp simd reduction(inscan, + : acc)
      | ^
1 warning generated.

While on gcc it suceeds.

fhahn

fhahn commented on Apr 29, 2025

@fhahn
Contributor

What's the behavior of #pragma omp scan inclusive(acc), how is it encoded in LLVM? cc @Meinersbur @alexey-bataev

Meinersbur

Meinersbur commented on Apr 29, 2025

@Meinersbur
Member

bd1c03d

I don't know what happens with a simd inscan though. One of the lowered implementation loops might just not be vectorizable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @fhahn@Meinersbur@EugeneZelenko@llvmbot@orpheezt

        Issue actions

          [LoopVectorize] Fails on OpenMP SIMD Prefix Sum · Issue #135576 · llvm/llvm-project