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

            Bug ID: 51245
           Summary: [X86][SSE] Reduce FPU->GPR traffic by performing fcmp
                    logic on FPU
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected],
                    [email protected]

https://godbolt.org/z/o7zzn7Gc6

bool f32cmp2(float x, float y, float z, float w) {
    return (x < y) != (z < w);
}

clang -g0 -O3 -march=btver2 

f32cmp2:
  vucomiss %xmm0, %xmm1
  seta %cl
  vucomiss %xmm2, %xmm3
  seta %al
  xorb %cl, %al
  retq

We can reduce fpu->gpr traffic by using 2 x cmpss instead, performing the xor
on the fpu and then just transferring the result:

f32cmp2:
  vcmpltss %xmm1, %xmm0, %xmm0
  vcmpltss %xmm3, %xmm2, %xmm2
  vxorps %xmm0, %xmm2, %xmm2
  vmovd %xmm2, %eax
  andb $1, %al

https://llvm.godbolt.org/z/xKWrPo88f

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to