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

            Bug ID: 42947
           Summary: Reduction loop - missing horizontal adds
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedb...@nondot.org
          Reporter: david.bolvan...@gmail.com
                CC: craig.top...@gmail.com, llvm-bugs@lists.llvm.org,
                    llvm-...@redking.me.uk, spatel+l...@rotateright.com

float Red(float* V)
{
    float sum = 0.f;
    for (int I = 0; I < 4; ++I)
    {
        sum += V[I];
    }
    return sum;
}

Clang -Ofast  -march=skylake -mavx2

Red(float*):                               # @Red(float*)
        vmovupd xmm0, xmmword ptr [rdi]
        vpermilpd       xmm1, xmm0, 1   # xmm1 = xmm0[1,0]
        vaddps  xmm0, xmm0, xmm1
        vmovshdup       xmm1, xmm0      # xmm1 = xmm0[1,1,3,3]
        vaddss  xmm0, xmm0, xmm1
        ret

Newest MSVC:
V$ = 8
float Red(float *) PROC                                    ; Red, COMDAT
        vmovups xmm0, XMMWORD PTR [rcx]
        vhaddps xmm1, xmm0, xmm0
        vhaddps xmm0, xmm1, xmm1
        ret     0
float Red(float *) ENDP   

Current codegen: https://godbolt.org/z/FSy0Ca

-- 
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

Reply via email to