[llvm-bugs] [Bug 48625] New: Incorrect codegen for #pragma omp simd loop at -O1
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Dec 29 15:39:50 PST 2020
https://bugs.llvm.org/show_bug.cgi?id=48625
Bug ID: 48625
Summary: Incorrect codegen for #pragma omp simd loop at -O1
Product: clang
Version: trunk
Hardware: Macintosh
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: LLVM Codegen
Assignee: unassignedclangbugs at nondot.org
Reporter: damatthews at smu.edu
CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
richard-llvm at metafoo.co.uk
The following program leads to incorrect codegen on x86-64 when compiled with
'-fopenmp-simd -O1': only every 4th (SSE) or 8th (AVX) element is summed for
large n. Changing the optimization level or enabling either FIX1 or FIX2 in the
code avoids the problem. The problem occurs in both C and C++ mode and
seemingly for any x86-64 uarch. Example of incorrect ASM:
https://godbolt.org/z/17n8bP.
```C
#ifdef __cplusplus
#define restrict __restrict
#endif
#define FIX1 0
#define FIX2 0
void sum(int n, const float* A,
#if FIX1
float* restrict value)
#else
float* value_)
#endif
{
#if !FIX1 && !FIX2
float* restrict value = (float* restrict)value_;
#endif
#if FIX2
float tmp = *value_;
float* value = &tmp;
#endif
#pragma omp simd
for (int i = 0;i < n;i++) *value += A[i];
#if FIX2
*value_ = tmp;
#endif
}
```
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201229/cd0ae44b/attachment.html>
More information about the llvm-bugs
mailing list