https://bugs.llvm.org/show_bug.cgi?id=52266
Bug ID: 52266
Summary: -ffp-contract=on prevents vectorization of reduction
loop
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Loop Optimizer
Assignee: unassignedb...@nondot.org
Reporter: craig.top...@gmail.com
CC: llvm-bugs@lists.llvm.org
Compiling this function with -ffp-contract=on does not vectorize when compiler
for -march=haswell. It works for -ffp-contract=off or -ffp-contract=fast
float foo(float *a, float *b, int n) {
float sum = 0.0f;
for (int i = 0; i != n; ++i) {
#pragma clang fp reassociate(on)
sum += a[i] * b[i];
}
return sum;
}
https://godbolt.org/z/cdv8dKPj9
I believe the problems is that the -ffp-contract=on causes the multiply and
accumulate in the loop to become a fmuladd intrinsic in the frontend. This
prevents the reduction recurrence from being detected since it is not an FAdd
instruction. With -ffp-contract=off or fast, there are separate fmul and fadd
instructions.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs