[llvm-bugs] [Bug 50682] New: Clang doesn't honor unroll #pragma to disable loop unrolling
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Jun 11 09:33:13 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=50682
Bug ID: 50682
Summary: Clang doesn't honor unroll #pragma to disable loop
unrolling
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: kobalicek.petr at gmail.com
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
neeilans at live.com, richard-llvm at metafoo.co.uk
Clang doesn't honor unroll #pragma to disable loop unrolling. I tried the
following 3 approaches to disable loop unrolling, but it's never honored. The
code is always autovectorized and unrolled regardless of #pragmas used.
Is there any way to make clang not unroll loops? Because in many cases I know
the loops will have very few iterations and I mark them with compiler specific
pragmas to not unroll, however, clang doesn't really honor them.
Compile flags:
-O2 -fno-math-errno -mavx2 -std=c++2a
The problem happens with -O2, -O3, and even -Os.
Sample code:
#include <stdint.h>
uint32_t countBits1(uint32_t* x, uint32_t n) {
uint32_t count = 0;
#pragma clang loop unroll(disable)
for (uint32_t i = 0; i < n; i++) {
count += __builtin_popcount(x[i]);
}
return count;
}
uint32_t countBits2(uint32_t* x, uint32_t n) {
uint32_t count = 0;
#pragma nounroll
for (uint32_t i = 0; i < n; i++) {
count += __builtin_popcount(x[i]);
}
return count;
}
uint32_t countBits3(uint32_t* x, uint32_t n) {
uint32_t count = 0;
#pragma unroll(1)
for (uint32_t i = 0; i < n; i++) {
count += __builtin_popcount(x[i]);
}
return count;
}
Compile explorer:
https://godbolt.org/z/EcoGqoaYG
--
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/20210611/9e806912/attachment-0001.html>
More information about the llvm-bugs
mailing list