[llvm] [X86][DAG] remove LowerFCanonicalize (PR #188127)

Ulrich Weigand via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 27 05:19:38 PDT 2026


uweigand wrote:

> Does it mean that "strictness" is a property of an operation, not a function? And we can choose strict or non-strict form at will?
> 
> What if the program is compiled with fast-math flags?

This is all a bit confusing to me, and maybe some things do need to be clarified further.  From the current LLVM IR documentation, some floating-point characteristics are defined as properties of an operation, others are defined as properties of a function.

The choice whether to use regular or strict opcodes is per-operation.  (However, apparently there have been some related per-function rules added as well, see below.)   Also, fast-math flags are a property of an operation (where only regular opcodes may carry fast-math flags; strict opcodes cannot).  In general, it seems to me that using per-operation properties would be preferable wherever possible, if only to avoid complicating inlining.

Then, there is the per-function "strictfp" flag, which primarily is about preventing the compiler from *creating* additional floating-point operations that might trap (this cannot be a per-operation property as the operations do not previously exist).   Now, I find there's also the "denormal_fpenv" property, which is per-function for some reason - not sure why it has to be that way.

What I was referring to above is this statement under "Behavior of Floating-Point NaN values":
>Code that requires different behavior than this should use the [Constrained Floating-Point Intrinsics](https://llvm.org/docs/LangRef.html#constrainedfp). In particular, constrained intrinsics rule out the “Unchanged NaN propagation” case; they are guaranteed to return a QNaN.

I understand this statement to apply to any constrained intrinsics, even those that use `"fpexcept.ignore"`.

On the other hand, there's this statement under "Constrained Floating-Point Intrinsics":

>If any FP operation in a function is constrained then they all must be constrained. This is required for correct LLVM IR. Optimizations that move code around can create miscompiles if mixing of constrained and normal operations is done. The correct way to mix constrained and less constrained operations is to use the rounding mode and exception handling metadata to mark constrained intrinsics as having LLVM’s default behavior.

This would, strictly speaking, prohibit introduction of `STRICT_FMUL` unless all other floating-point operations in the function are changed to strict operations as well.

However, that requirement strikes me as overkill, specifically when introducing `"fpexcept.ignore"` strict operations.  I agree that once we require precise exception semantics, that would have to be a per-function decision, but as long as we do not, but only use strict operations to ensure IEEE SNaN->QNaN conversion, that should still work?


https://github.com/llvm/llvm-project/pull/188127


More information about the llvm-commits mailing list