[PATCH] D140294: clang: Replace implementation of __builtin_isnormal

Serge Pavlov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 20 00:28:36 PST 2022


sepavloff added a comment.

This change can have negative consequences in some cases. Some targets have dedicated instruction to test FP class and often this instruction is faster than arithmetic operations. Replacement of one operation with two arithmetic and two logic plus cost of FP constant materialization does not provide any visible benefit.

One of advantages that llvm.is_fpclass provides is the possibility for a target to use FCLASS instruction if it is available. Besides, llvm.is_fpclass incapsulates semantics of a class check, which is not identical to compare operations. Keeping the class checks in IR can facilitate FP-specific optimizations which provide different handing depending on possible FP classes. Fast math is one example, denormals is another.

I would propose to generate llvm.is_fpclass for all classification intrinsics (see D137811 <https://reviews.llvm.org/D137811>). Targets then may lower the intrinsic in a way most suitable way depending on ISA.


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

https://reviews.llvm.org/D140294



More information about the cfe-commits mailing list