sepavloff added a comment.

C standard function `fesetround` accepts rounding mode in the form of 
target-specific values like `FE_TONEAREST`. They usually represent 
corresponding bits in control register, so are different for different targets. 
`llvm.set_rounding` in contrast accepts rounding mode as target-independent 
value, the encoding is same as used in `FLT_ROUNDS`.

The difference between `fesetround` and `llvm.set_rounding` is same as for 
`fegetround` and `FLT_ROUNDS`. They differ in how rounding mode is specified, - 
as target-specific or as target-independent values respectively.

The intrinsic `llvm.set_rounding` was introduced to facilitate work on IR, 
because IR is (mainly) target-agnostic and defines like `FE_TONEAREST` are not 
available there. It would be nice to have a C builtin counterpart for 
`FLT_ROUNDS`, I don't know why the standard does not define it.

Implementation of `fesetround` with `set_rounding` would be very useful, but it 
requires translation of target-specific values for rounding mode into universal 
values and also checking availability of FPU, as `fesetround` returns value if 
rounding mode cannot be set. Both these checks are likely to require separate 
builtins.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144454

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to