[llvm] [DAG] Avoid strictfp nodes in lowering of llvm.fcanonicalize (PR #177399)

Serge Pavlov via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 18 22:35:19 PST 2026


spavloff wrote:

> Really the solution here is to just make targets directly select this to the correct instruction. 

Moving responsibility of lowering FCANONICALIZE to individual targets is certainly a convenient way to solve the problem. However, it increases the implementation effort for each target. As the possible implementation exists and is documented, it is natural to expect that this implementation should be realized in the generic CodeGen code rather than left to each backend.

> This is also assuming that the selector isn't optimizing fmul either. 

The selector must not optimize `x * 1.0 -> x` because it is wrong if x is SNaN. It is also incorrect if the target supports non-default denormal modes. The selector should emit instruction for the general case, specific optimizations should be made previously.

Anyway, the existing implementation suffer from the assumption that STRICT_FMUL is never optimized. Also using an operation that accesses FP environment is incorrect in the default mode. 


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


More information about the llvm-commits mailing list