[llvm-bugs] [Bug 51989] New: [X86] Failure to optimize float vector reduction to haddps

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Sep 27 13:51:56 PDT 2021


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

            Bug ID: 51989
           Summary: [X86] Failure to optimize float vector reduction to
                    haddps
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: gabravier at gmail.com
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, pengfei.wang at intel.com,
                    spatel+llvm at rotateright.com

#include <stddef.h>

typedef float simde_float32x2_t __attribute__((__vector_size__(8)));

float simde_vaddv_f32(simde_float32x2_t a) {
  float r = 0;

  for (size_t i = 0; i < (sizeof(a) / sizeof(a[0])); i++) {
    r += a[i];
  }

  return r;
}

With -O3 -mssse3, LLVM outputs this:

simde_vaddv_f32(float __vector(2)):
        movshdup        xmm1, xmm0                      # xmm1 = xmm0[1,1,3,3]
        addss   xmm0, xmm1
        ret

GCC instead manages this:

simde_vaddv_f32(float __vector(2)):
        haddps  xmm0, xmm0
        ret

-- 
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/20210927/d2b59c4b/attachment-0001.html>


More information about the llvm-bugs mailing list