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

            Bug ID: 34149
           Summary: Suboptimal codegen for "fast" minnum and maxnum
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedb...@nondot.org
          Reporter: san...@playingwithpointers.com
                CC: llvm-bugs@lists.llvm.org

On trunk, llc -O3 -mcpu=haswell on this program:

define <4 x double> @via_minnum(<4 x double> %x, <4 x double> %y) {
  %z = call fast <4 x double> @llvm.minnum.v4f64(<4 x double> %x, <4 x double>
%y) readnone
  ret <4 x double> %z
}

define <4 x double> @via_fcmp(<4 x double> %x, <4 x double> %y) {
  %c = fcmp ule <4 x double> %x, %y
  %z = select <4 x i1> %c, <4 x double> %x, <4 x double> %y
  ret <4 x double> %z
}

declare <4 x double> @llvm.minnum.v4f64(<4 x double>, <4 x double>)

generates:

        .text
        .file   "fast-min.ll"
        .globl  via_minnum              # -- Begin function via_minnum
        .p2align        4, 0x90
        .type   via_minnum,@function
via_minnum:                             # @via_minnum
        .cfi_startproc
# BB#0:
        vminpd  %ymm0, %ymm1, %ymm2
        vcmpunordpd     %ymm0, %ymm0, %ymm0
        vblendvpd       %ymm0, %ymm1, %ymm2, %ymm0
        retq
.Lfunc_end0:
        .size   via_minnum, .Lfunc_end0-via_minnum
        .cfi_endproc
                                        # -- End function
        .globl  via_fcmp                # -- Begin function via_fcmp
        .p2align        4, 0x90
        .type   via_fcmp,@function
via_fcmp:                               # @via_fcmp
        .cfi_startproc
# BB#0:
        vminpd  %ymm0, %ymm1, %ymm0
        retq
.Lfunc_end1:
        .size   via_fcmp, .Lfunc_end1-via_fcmp
        .cfi_endproc
                                        # -- End function

        .section        ".note.GNU-stack","",@progbits


Ideally we should be able to exploit the "fast" attribute on the minnum call to
generate the same assembly for @via_minnum as we do for @via_fcmp

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to