[DAG] Create fptoui.sat from clamped fptosi
authorDavid Green <david.green@arm.com>
Sun, 5 Dec 2021 09:25:52 +0000 (09:25 +0000)
committerDavid Green <david.green@arm.com>
Sun, 5 Dec 2021 09:25:52 +0000 (09:25 +0000)
commit57ff805a6da7a54434646af589455069459c667e
tree0fc19fe427edd4f532632bcfb77a1f62674de2bf
parentc22b110612600b0d0a8003f40b1cf6e37c4696c2
[DAG] Create fptoui.sat from clamped fptosi

As an extension to D111976, this converts clamp fptosi, clamped between
0 and (2^n)-1 to a fptoui.sat. This can greatly help on targets with
conversions that naturally saturate, such as Arm.

X86 disables the transform as some of the test cases increases in size.
A fptoui.sat necessitates a fp clamp without native support, so there is
little use in converting if the instruction is just going to be
expanded.

Differential Revision: https://reviews.llvm.org/D112428
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/Target/X86/X86ISelLowering.h
llvm/test/CodeGen/AArch64/fpclamptosat.ll
llvm/test/CodeGen/AArch64/fpclamptosat_vec.ll
llvm/test/CodeGen/ARM/fpclamptosat.ll
llvm/test/CodeGen/RISCV/fpclamptosat.ll
llvm/test/CodeGen/Thumb2/mve-fpclamptosat_vec.ll
llvm/test/CodeGen/WebAssembly/fpclamptosat.ll
llvm/test/CodeGen/WebAssembly/fpclamptosat_vec.ll