[CostModel] Add basic fptoi_sat costs
authorDavid Green <david.green@arm.com>
Wed, 27 Apr 2022 08:30:00 +0000 (09:30 +0100)
committerDavid Green <david.green@arm.com>
Wed, 27 Apr 2022 08:30:00 +0000 (09:30 +0100)
commit4a8c13a6f42e9c58af64421790509cc58208859b
treed3bd029c244a968f0895bbeed69b3838f167bb41
parentc1e94591bcc95f36da0372080c455b09af8c46fd
[CostModel] Add basic fptoi_sat costs

This adds some basic fptosi_sat and fptoui_sat target independent cost
modelling. The fptosi_sat is modelled as a fmin/fmax to saturate the
value, followed by a fp convert. The signed values then have an
additional fcmp+select for handling Nan correctly.

The AArch64/Arm costs may be more incorrect, as the instruction exist
natively. This can be fixed with target specific cost updates.

Differential Revision: https://reviews.llvm.org/D124269
llvm/include/llvm/CodeGen/BasicTTIImpl.h
llvm/test/Analysis/CostModel/AArch64/fptoi_sat.ll
llvm/test/Analysis/CostModel/ARM/fptoi_sat.ll
llvm/test/Analysis/CostModel/X86/fptoi_sat.ll