[PATCH] D53794: [TargetLowering] expandFP_TO_UINT - avoid FPE due to out of range conversion (PR17686)

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 27 13:43:45 PDT 2018


RKSimon created this revision.
RKSimon added reviewers: janusz, rsmith, efriedma, atanasyan, jnspaulsson, uweigand, smaksimovic, craig.topper, spatel.
Herald added subscribers: jrtc27, sdardis.

PR17686 demonstrates that for some targets FP exceptions can fire in cases where the FP_TO_UINT is expanded using a FP_TO_SINT instruction.

The existing code converts both the inrange and outofrange cases using FP_TO_SINT and then selects the result. As suggested on the ticket, this patch changes this to pre-select the FP_TO_SINT input and the offset adjustment. Given this is generic expansion code I'm not sure if it'd be a good idea to include FPE and non-FPE codepaths driven by a target feature flag?

The targets that use the expansion tend to see an increase in codegen (apart from X87 which sees some much nicer code...) - some look like they may benefit from a target specific lowering, others (X86-SSE) just uncovers some poor codegen that needs addressing.

In future patches I'll be adding VectorLegalizer support for expandFP_TO_UINT which helps X86-SSE in particular (beyond the current codegen), and I'm intending to fix the duplicate X86-SSE CMPSS and UCOMISS comparisons as well.


Repository:
  rL LLVM

https://reviews.llvm.org/D53794

Files:
  lib/CodeGen/SelectionDAG/TargetLowering.cpp
  test/CodeGen/Mips/2008-07-07-Float2Int.ll
  test/CodeGen/Mips/msa/f16-llvm-ir.ll
  test/CodeGen/SystemZ/fp-conv-10.ll
  test/CodeGen/SystemZ/fp-conv-12.ll
  test/CodeGen/X86/fp-cvt.ll
  test/CodeGen/X86/ftrunc.ll
  test/CodeGen/X86/half.ll
  test/CodeGen/X86/scalar-fp-to-i64.ll
  test/CodeGen/X86/vec_fp_to_int.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53794.171407.patch
Type: text/x-patch
Size: 101485 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181027/6f9b77cf/attachment.bin>


More information about the llvm-commits mailing list