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

            Bug ID: 45036
           Summary: fast math flags on fcmp scalarizes on aarch64
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: AArch64
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected],
                    [email protected], [email protected],
                    [email protected]

Created attachment 23176
  --> https://bugs.llvm.org/attachment.cgi?id=23176&action=edit
ll that demonstrates the problem

Any fast math flags on an fcmp seem to cause the aarch64 backend to emit a
sequence of scalar fcmp instructions instead of a single vector fcmgt
instruction.

The following ll shows the same comparison, with and without a fast math flag.
I turned them all on, but it seems that any fast math flag will do.

define <4 x i1> @good(<4 x float> %a, <4 x float> %b) {
  %c = fcmp olt <4 x float> %a, %b
  ret <4 x i1> %c
}

define <4 x i1> @bad(<4 x float> %a, <4 x float> %b) {
  %c = fcmp fast olt <4 x float> %a, %b
  ret <4 x i1> %c
}

Output from llc -march=aarch64 -filetype=asm fcmgt.ll  -o -

...
good:  
        fcmgt   v0.4s, v1.4s, v0.4s
        xtn     v0.4h, v0.4s
        ret

...

bad:
        mov     s2, v1.s[1]
        mov     s3, v0.s[1]
        fcmp    s3, s2
        csetm   w8, lt
        fcmp    s0, s1
        mov     s4, v1.s[2]
        mov     s2, v0.s[2]
        csetm   w9, lt
        mov     s3, v1.s[3]
        mov     s0, v0.s[3]
        fcmp    s2, s4
        fmov    s1, w9
        csetm   w9, lt
        fcmp    s0, s3
        mov     v1.s[1], w8
        mov     v1.s[2], w9
        csetm   w8, lt
        mov     v1.s[3], w8
        xtn     v0.4h, v1.4s
        ret
...

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