[PATCH] D124269: [CostModel] Add basic fptoi_sat costs

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 25 08:04:55 PDT 2022


dmgreen added a comment.

In D124269#3471794 <https://reviews.llvm.org/D124269#3471794>, @david-arm wrote:

> Hi @dmgreen, just out of curiosity why do we only care about NaNs for the signed case? Looking at the documentation for llvm.fptosi.sat and llvm.fptoui.sat they both state that "if any argument is NaN, zero is returned". So don't you have to do a fcmp+select in both cases?

The code that creates it is here: https://github.com/llvm/llvm-project/blob/5ad07ac400dad1cbc7c7c0a5e6325165da993fb1/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp#L9175. The short version is that the unsigned case has clamped the minimum to 0 already. For the signed version 0 is in the middle of its range so needs an extra check.



================
Comment at: llvm/test/Analysis/CostModel/X86/fptoi_sat.ll:735
+;
+; AVX-LABEL: 'casts'
+; AVX-NEXT:  Cost Model: Found an estimated cost of 9 for instruction: %f32s1 = call i1 @llvm.fptosi.sat.i1.f32(float undef)
----------------
RKSimon wrote:
> These need stripping now
Oh sorry, I was on autopilot a bit, with how many different check lines there are.
I've rebased them onto what is hopefully a better baseline.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124269/new/

https://reviews.llvm.org/D124269



More information about the llvm-commits mailing list