[X86] Move x86_64 fp128 conversion to libcalls from type legalization to DAG legalization
authorCraig Topper <craig.topper@intel.com>
Wed, 11 Sep 2019 21:30:09 +0000 (21:30 +0000)
committerCraig Topper <craig.topper@intel.com>
Wed, 11 Sep 2019 21:30:09 +0000 (21:30 +0000)
commit08474ca091fe2b2eee6113381bf29386d9294b20
tree8e1c3001b71c1d9ebf9507df02fad8c18191d1ae
parent666af6714c8166fe381daf776a36fc81730cf59c
[X86] Move x86_64 fp128 conversion to libcalls from type legalization to DAG legalization

fp128 is considered a legal type for a register, but has almost no legal operations so everything needs to be converted to a libcall. Previously this was implemented by tricking type legalization into softening the operations with various checks for "is legal in hardware register" to change the behavior to still use f128 as the resulting type instead of converting to i128.

This patch abandons this approach and instead moves the libcall conversions to LegalizeDAG. This is the approach taken by AArch64 where they also have a legal fp128 type, but no legal operations. I think this is more in spirit with how SelectionDAG's phases are supposed to work.

I had to make some hacks for STRICT_FP_ROUND because some of the strict FP handling checks if ISD::FP_ROUND is Legal for a given result type, but I had to make ISD::FP_ROUND Custom to allow making a libcall when the input is f128. For all other types the Custom handler just returns the original node. These hacks are incomplete and don't work for a strict truncate from f128, but I don't think it worked before either since LegalizeFloatTypes doesn't know about strict ops yet. I've also raised PR43209 against AArch64 which currently crashes on a strict ftrunc from f64->f32 because of FP_ROUND being marked Custom for the same reason there.

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

llvm-svn: 371672
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86ISelLowering.h
llvm/test/CodeGen/X86/fp128-cast.ll
llvm/test/CodeGen/X86/fp128-compare.ll
llvm/test/CodeGen/X86/fp128-i128.ll