[PATCH] D94163: [RISCV] Set dependency on floating point CSRs, 1/3

Serge Pavlov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 1 21:10:09 PST 2021


sepavloff added a comment.
Herald added a subscriber: vkmr.

In D94163#2489101 <https://reviews.llvm.org/D94163#2489101>, @craig.topper wrote:

> In D94163#2489020 <https://reviews.llvm.org/D94163#2489020>, @sepavloff wrote:
>
>> In D94163#2482528 <https://reviews.llvm.org/D94163#2482528>, @craig.topper wrote:
>>
>>> I still don't understand why the existence of static rounding modes in the ISA requires that we have to use them for the default environment. X86 doesn't have static rounding mode prior to AVX512 so uses dynamic in the default mode.
>>
>> It is more convenient. Instructions with static rounding mode do not depend on `frm` so they may be scheduled more freely. Besides function with static only FP instructions may be safely called from non-default FP environment. Targets without static rounding mode don't have such possibility.
>
> If there’s no write to frm then there shouldn’t be a scheduling issue.

Sure. Such issue rises when there is write to `frm`.  Consider the following pseudo code:

  float a = ...
  for (int i = ...) {
    fesetround(FE_TOWARDZERO); // csrw frm, 1
    ...
    x[i] += floor(a); // fcvt ..., rdn

`floor(a)` is a loop invariant and could be hoisted off the loop. It is possible as `fcvt` uses static rounding. However if `fcvt` uses dynamic rounding, it depends on `frm`, which is changed above, so it cannot be moved out of the loop.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94163



More information about the llvm-commits mailing list