[PATCH] D71742: Added intrinsics for access to FP environment

Serge Pavlov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 22 21:54:59 PST 2019


sepavloff added a comment.

In D71742#1793243 <https://reviews.llvm.org/D71742#1793243>, @kpn wrote:

> I don't see the need. Changing the FP environment in a mixed environment program is the responsibility of the programmer, and standard calls already exist for this.


This is about inlining. In the code like this:

  double f1(double x, double y) {
    return x + y;
  }
  double f2(double x, double y) {
    #pragma STDC FENV_ACCESS ON
    ...
    return f1(x, y);
  }

compiler might inline call to `f1` in `f2`. However the inlined function `f1` expects default FP environment but is called in some other one.

In D71742#1793447 <https://reviews.llvm.org/D71742#1793447>, @efriedma wrote:

> > It is expected that targets will implement custom lowering to proper machine instructions for better performance.
>
> Do you have any performance numbers?


I don't have them. But there are some considerations why optimization may be desirable:

- For some targets FP environment is a content of 1 or 2 registers. It this case custom lowering can store the environment in registers and avoid expenses for function calls and memory operations.
- Some targets encode FP environment in instructions. In this case these intrinsics shoul not produce any code.
- Probably we need to reset FP environment before calls to external functions in strictfp function and restore it upon return. In this case number of calls to such intrinsics may be large enough.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71742/new/

https://reviews.llvm.org/D71742





More information about the llvm-commits mailing list