[PATCH] D115804: [CodeGen] use saturating FP casts when compiling with "no-strict-float-cast-overflow"

Sanjay Patel via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 15 09:19:26 PST 2021


spatel added a comment.

In D115804#3195002 <https://reviews.llvm.org/D115804#3195002>, @nikic wrote:

> Looks reasonable. Making float to int cast well defined is exactly why these intrinsics exist. Should we also drop the "string-float-cast-overflow" attribute, as UB is now prevented in a different way?

Yes, that sounds like a good enhancement. The only in-tree use of the attribute is in DAGCombiner. Make that a follow-up patch or two since it crosses into LLVM? 
If we care about perf of the generated code in those cases, then we need to add something to the optimizer or codegen to recognize patterns like this:

  define float @s(float %x) {
    %i = call i32 @llvm.fptosi.sat.i32.f32(float %x)
    %f = sitofp i32 %i to float
    ret float %f
  }


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

https://reviews.llvm.org/D115804



More information about the cfe-commits mailing list