[PATCH] D106362: [FPEnv][InstSimplify] Enable more folds for constrained fadd

Serge Pavlov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 1 06:26:11 PDT 2021


sepavloff added a comment.

In D106362#3035988 <https://reviews.llvm.org/D106362#3035988>, @nlopes wrote:

> Ouch, this is a long thread.
>
> If I understand correctly, an important missing feature in Alive2 is support for multiple rounding modes. I didn't implement that so far mostly because I was under the impression that rounding modes was still a working in progress thing. Is this true or is it mostly settled in stone?

The support of non-default rounding modes is still not as mature as it should be.

> I would appreciate if someone could point me out to the functions that can change the rounding mode (e.g., a function call may change the rounding mode, right?  is the rounding mode global per thread or per process?). If I get to understand how this thing works I'm happy to implement it in Alive2 :)

There are two kinds of rounding mode, static and dynamic. Availability of them depends on the target. The dynamic rounding mode is more universal, most targets support it. This kind of rounding mode is set by a write to a special hardware register. If IR it is done by the intrinsic `llvm.set_rounding`. Another intrinsic, 'llvm.flt_rounds` can be used to read the value of dynamic rounding mode. The dynamic rounding mode is defined for each thread. Operations that use dynamic rounding mode are represented in IR by constrained intrinsics like:

  %add = call float @llvm.experimental.constrained.fadd.f32(float %a, float 0.0, metadata !"round.dynamic", metadata !"fpexcept.strict")

Support of the dynamic rounding mode is more or less ready.
The static rounding mode is available on some targets, for example on RISC-V. In this case rounding mode is encoded as a part of processor instruction, it is not kept in a separate register. In IR the static rounding mode is represented by special metadata operands like:

  %add = call float @llvm.experimental.constrained.fadd.f32(float %a, float 0.0, metadata !"round.upward", metadata !"fpexcept.strict")

Support of the static rounding more is still weak, mainly because the support of constrained intrinsics for such targets is limited.


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

https://reviews.llvm.org/D106362



More information about the llvm-commits mailing list