[LegalizeTypes][X86] Improve ExpandIntRes_FP_TO_SINT/ExpandIntRes_FP_TO_UINT when...
authorCraig Topper <craig.topper@sifive.com>
Mon, 30 Aug 2021 18:53:18 +0000 (11:53 -0700)
committerCraig Topper <craig.topper@sifive.com>
Mon, 30 Aug 2021 20:12:59 +0000 (13:12 -0700)
commit201f6446da5643fb13cbbbe58c58311a70a9bd43
treeca84e496a7a76af12739829462840ed5976e0e22
parent789f01283d52065b10049b58a3288c4abd1ef351
[LegalizeTypes][X86] Improve ExpandIntRes_FP_TO_SINT/ExpandIntRes_FP_TO_UINT when input is SoftPromoteHalf.

Instead of splitting off the fp16 to float conversion and generating
a libcall, we should split the operation into fp16 to float and float
to integer operations. This will allow the float to integer conversion
to go through any custom handling the target has. If the target doesn't
have custom handling then we should come back to ExpandIntRes_FP_TO_SINT/
ExpandIntRes_FP_TO_UINT automatically to create the libcall.

This avoids generating libcalls on 32-bit X86. These library functions may
not exist in 32-bit libgcc. At least for LLVM, we never generate them when
hardware floating point instructions are available.

Differential Revision: https://reviews.llvm.org/D108933
llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
llvm/test/CodeGen/X86/half.ll