This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by LiuChen3 on Jan 14 2020, 11:05 PM.

Details

Summary

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. In 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.

Diff Detail

Event Timeline

LiuChen3 created this revision.Jan 14 2020, 11:05 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 14 2020, 11:05 PM
LiuChen3 updated this revision to Diff 238178.Jan 14 2020, 11:13 PM

Fix format problems.

craig.topper added inline comments.Jan 15 2020, 12:06 AM
llvm/lib/Target/X86/X86InsertWait.cpp
26

This is unused

27

This is unused

41

This is unused. Those were just the obvious ones. Please prune to just what's necessary.

LiuChen3 marked an inline comment as done.Jan 15 2020, 12:54 AM
LiuChen3 added inline comments.
llvm/lib/Target/X86/X86InsertWait.cpp
41

Sorry for adding redundant header files. Thanks to point out.

LiuChen3 updated this revision to Diff 238185.Jan 15 2020, 12:55 AM

remove redundant header files.

This revision is now accepted and ready to land.Jan 15 2020, 10:12 AM
This revision was automatically updated to reflect the committed changes.