[all-commits] [llvm/llvm-project] 016f42: [X86] Add custom lowering for lrint/llrint to eith...

topperc via All-commits all-commits at lists.llvm.org
Tue Feb 4 16:17:13 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 016f42e3dcd80431d1a5a17c92f83b3a8a1a601c
      https://github.com/llvm/llvm-project/commit/016f42e3dcd80431d1a5a17c92f83b3a8a1a601c
  Author: Craig Topper <craig.topper at intel.com>
  Date:   2020-02-04 (Tue, 04 Feb 2020)

  Changed paths:
    M llvm/lib/Target/X86/X86ISelLowering.cpp
    M llvm/lib/Target/X86/X86ISelLowering.h
    M llvm/lib/Target/X86/X86InstrAVX512.td
    M llvm/lib/Target/X86/X86InstrFPStack.td
    M llvm/lib/Target/X86/X86InstrSSE.td
    M llvm/test/CodeGen/X86/llrint-conv.ll
    M llvm/test/CodeGen/X86/lrint-conv-i32.ll
    M llvm/test/CodeGen/X86/lrint-conv-i64.ll

  Log Message:
  -----------
  [X86] Add custom lowering for lrint/llrint to either cvtss2si/cvtsd2si or fist.

lrint/llrint are defined as rounding using the current rounding
mode. Numbers that can't be converted raise FE_INVALID and an
implementation defined value is returned. They may also write to
errno.

I believe this means we can use cvtss2si/cvtsd2si or fist to
convert as long as -fno-math-errno is passed on the command line.
Clang will leave them as libcalls if errno is enabled so they
won't become ISD::LRINT/LLRINT in SelectionDAG.

For 64-bit results on a 32-bit target we can't use cvtss2si/cvtsd2si
but we can use fist since it can write to a 64-bit memory location.
Though maybe we could consider using vcvtps2qq/vcvtpd2qq on avx512dq
targets?

gcc also does this optimization.

I think we might be able to do this with STRICT_LRINT/LLRINT as
well, but I've left that for future work.

Differential Revision: https://reviews.llvm.org/D73859




More information about the All-commits mailing list