[llvm] [SDAG] Fix deferring constrained function calls (PR #153029)
Serge Pavlov via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 18 10:37:25 PDT 2025
spavloff wrote:
> How about a function where rounding mode matters and is different in different parts of the function calling a function that calls a function that changes the rounding mode? I don't think we can model that, especially if the functions are in different compilations.
A function that changes the rounding mode can be either external or intrinsic. External functions (like `fesetround`) are considered to have side effects. For a DAG, this means that the chain argument for such a call is obtained using `SelectionDAGBuilder::getRoot`, which flushes all pending constrained intrinsics. This prevents FP operations from moving past the function call into regions that might have a different rounding mode.
If the rounding mode is changed by an intrinsic function call (like `llvm.set_rounding`), that function has the property `IntrInaccessibleMemOnly`, so it also has a chain argument, which is now obtained by `SelectionDAGBuilder::getRoot`. Therefore, in this case FP operations also must be sequenced correctly.
It seems the current implementation should correctly treat the functions that change the rounding mode.
https://github.com/llvm/llvm-project/pull/153029
More information about the llvm-commits
mailing list