[llvm-bugs] [Bug 43574] New: Vectorized fp min/max reduction loop uses minnum/maxnum for horizontal reduction, but not loop body

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Oct 5 10:11:09 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=43574

            Bug ID: 43574
           Summary: Vectorized fp min/max reduction loop uses
                    minnum/maxnum for horizontal reduction, but not loop
                    body
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedbugs at nondot.org
          Reporter: craig.topper at gmail.com
                CC: llvm-bugs at lists.llvm.org

For a min/max reduction loop, the vectorizer adds fast math flags to the
fcmp/select for the horizontal reduction after the loop. But the selects in the
loop don't have fastmath flags. This leads to InstCombine creating
fmaxnum/fminnum intrinsics for the horizontal reduction. X86 codegens both the
loop body and the horizontal reduction to the FP min/max instructions so the
difference didn't end up mattering. It just looked inconsistent.

clang -Ofast -march=skylake-avx512

float a[1024];

float foo() {
  float min = 0.0;
  for (int i = 0; i != 1024; ++i)
    min = min < a[i] ? min : a[i];

  return min;
}

https://godbolt.org/z/AMWYWm

-- 
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/20191005/c1350d04/attachment-0001.html>


More information about the llvm-bugs mailing list