[PATCH] D71840: [FPEnv][X86] More strict int <-> FP conversion fixes

Ulrich Weigand via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 23 06:30:34 PST 2019


uweigand created this revision.
uweigand added reviewers: craig.topper, andrew.w.kaylor, cameron.mcinally, kpn, RKSimon.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

I've noticed several additional problems with the int <-> FP conversion logic both in common code and in the X86 target.  In particular:

- The STRICT_FP_TO_UINT expansion emits a floating-point compare.  This compare can raise exceptions and therefore needs to be a strict compare.  I've made it signaling (even though quiet would also be correct) as signaling is the more usual default for an LT.  This code exists both in common code and in the X86 target.

- The STRICT_UINT_TO_FP expansion algorithm was incorrect for strict mode: it emitted two STRICT_SINT_TO_FP nodes and then used a select to choose one of the results.  This can cause spurious exceptions by the STRICT_SINT_TO_FP that ends up not chosen. I've fixed the algorithm to use only a single STRICT_SINT_TO_FP instead.

- The !isStrictFPEnabled logic in DoInstructionSelection would sometimes do the wrong thing because it calls getOperationAction using the result VT.  But for some opcodes, incuding [SU]INT_TO_FP, getOperationAction needs to be called using the operand VT.

- There was some (obsolete?) code in X86DAGToDAGISel::Select that would mutate STRICT_FP_TO_[SU]INT to non-strict versions unnecessarily.

Note that these changes (including the common code ones) affect primarily X86 codegen.  @craig.topper, does this look good to you?


https://reviews.llvm.org/D71840

Files:
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
  llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86InstrAVX512.td
  llvm/lib/Target/X86/X86InstrSSE.td
  llvm/test/CodeGen/SystemZ/fp-strict-conv-10.ll
  llvm/test/CodeGen/SystemZ/fp-strict-conv-12.ll
  llvm/test/CodeGen/X86/fp-intrinsics-flags.ll
  llvm/test/CodeGen/X86/fp-intrinsics.ll
  llvm/test/CodeGen/X86/fp-strict-scalar-fptoint.ll
  llvm/test/CodeGen/X86/fp80-strict-scalar.ll
  llvm/test/CodeGen/X86/vec-strict-fptoint-128.ll
  llvm/test/CodeGen/X86/vec-strict-fptoint-256.ll
  llvm/test/CodeGen/X86/vec-strict-fptoint-512.ll
  llvm/test/CodeGen/X86/vector-constrained-fp-intrinsics.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71840.235137.patch
Type: text/x-patch
Size: 173741 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191223/37bc2177/attachment-0001.bin>


More information about the llvm-commits mailing list