[all-commits] [llvm/llvm-project] 10e789: [FPEnv] Get rid of extra moves in fpenv calls

Serge Pavlov via All-commits all-commits at lists.llvm.org
Tue Jun 6 00:56:25 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 10e7899818803029d2f91a20c67f5a1d75781b8a
      https://github.com/llvm/llvm-project/commit/10e7899818803029d2f91a20c67f5a1d75781b8a
  Author: Serge Pavlov <sepavloff at gmail.com>
  Date:   2023-06-06 (Tue, 06 Jun 2023)

  Changed paths:
    M llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
    A llvm/test/CodeGen/X86/fpenv-combine.ll
    M llvm/test/CodeGen/X86/fpenv.ll

  Log Message:
  -----------
  [FPEnv] Get rid of extra moves in fpenv calls

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.

Differential Revision: https://reviews.llvm.org/D150437




More information about the All-commits mailing list