[PATCH] D150437: [FPEnv] Get rid of extra moves in fpenv calls

Serge Pavlov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 12 03:56:56 PDT 2023


sepavloff created this revision.
sepavloff added reviewers: arsenm, nikic, RKSimon, greened, craig.topper, shchenz.
Herald added subscribers: StephenFan, ecnelises, pengfei, hiraditya.
Herald added a project: All.
sepavloff requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.

If intrinsic `get_fpenv` or `set_fpenv` is lowered to the form where FP
environment is represented as a region in memory, extra moves can
appear. For example the code:

  define void @func_01(ptr %ptr) {
    %env = call i256 @llvm.get.fpenv.i256()
    store i256 %env, ptr %ptr
    ret void
  }

produces DAG:

  ch = get_fpenv_mem ch, memory_region
  val: i256, ch = load ch, memory_region
  ch = store ch, ptr, val

In this case the extra moves can be avoided if `get_fpenv_mem` got
pointer to the memory where the FP environment should be finally placed.

This change implement such optimization for this use case.

Depends on D71742 <https://reviews.llvm.org/D71742>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150437

Files:
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/test/CodeGen/X86/fpenv.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150437.521599.patch
Type: text/x-patch
Size: 12160 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230512/2dec6553/attachment.bin>


More information about the llvm-commits mailing list