[PATCH] D72750: [X86] Insert wait instruction after X87 instructions which could raise float-point exception.

LiuChen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 14 23:12:36 PST 2020


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

This patch insert wait after X87 instruction to make sure floating-point exceptions synchronized.

The rule is simple:

1. If the X87 instruction don't raise float exception nor is a load/store instruction, or is a x87 control instruction, don't insert wait.
2. If the X87 instruction is an instruction which the following instruction is an X87 exception synchronizing X87 instruction, don't insert wait.
3. For other situations, insert wait instruction.

FNINIT, FNSTENV, FNSAVE, FNSTSW, FNSTCW, and FNCLEX instructions don't check for pending unmasked
exceptions, they don't synchronize exceptions.

This patch also modify some mayRaiseFPException flag which set in D68854 <https://reviews.llvm.org/D68854>. In D68854 <https://reviews.llvm.org/D68854>, we set mayRaiseFPException =1
in each X87 instruction which could raise Floating-Point Exceptions.  Now, we don't set this flag to 1 in instruction which
only have #IS float-point Exceptions.


https://reviews.llvm.org/D72750

Files:
  llvm/lib/Target/X86/CMakeLists.txt
  llvm/lib/Target/X86/X86.h
  llvm/lib/Target/X86/X86FloatingPoint.cpp
  llvm/lib/Target/X86/X86InsertWait.cpp
  llvm/lib/Target/X86/X86InstrFPStack.td
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/test/CodeGen/X86/O0-pipeline.ll
  llvm/test/CodeGen/X86/O3-pipeline.ll
  llvm/test/CodeGen/X86/constrained-fp80-trunc-ext.ll
  llvm/test/CodeGen/X86/fp-intrinsics.ll
  llvm/test/CodeGen/X86/fp-strict-libcalls-msvc32.ll
  llvm/test/CodeGen/X86/fp-strict-scalar-cmp.ll
  llvm/test/CodeGen/X86/fp-strict-scalar-fptoint.ll
  llvm/test/CodeGen/X86/fp-strict-scalar-inttofp.ll
  llvm/test/CodeGen/X86/fp-strict-scalar-round.ll
  llvm/test/CodeGen/X86/fp-strict-scalar.ll
  llvm/test/CodeGen/X86/fp128-cast-strict.ll
  llvm/test/CodeGen/X86/fp80-strict-scalar-cmp.ll
  llvm/test/CodeGen/X86/fp80-strict-scalar.ll
  llvm/test/CodeGen/X86/vec-strict-128.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/vec-strict-inttofp-128.ll
  llvm/test/CodeGen/X86/vec-strict-inttofp-256.ll
  llvm/test/CodeGen/X86/vec-strict-inttofp-512.ll
  llvm/test/CodeGen/X86/vector-constrained-fp-intrinsics.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72750.238173.patch
Type: text/x-patch
Size: 191655 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200115/c0d98fcd/attachment-0001.bin>


More information about the llvm-commits mailing list