[PATCH] D139311: InstCombine: Match pattern that appears in clang's __builtin_isnormal

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 16 04:22:13 PST 2022


arsenm added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:1217-1220
+/// Matches canonical form of isnan, fcmp ord x, 0
+static bool matchIsNaN(FCmpInst::Predicate P, Value *LHS, Value *RHS) {
+  return P == FCmpInst::FCMP_ORD && match(RHS, m_AnyZeroFP());
+}
----------------
sepavloff wrote:
> As this is `fcmp ord`, the name `matchIsNotNaN` would be better.
> 
> IR producer (not necessarily clang) may chose any form of NaN check, so the check must test both forms, `fcmp ord x, const` or `fcmp ord x, x`.
And that get canonicalized into fcmp ord with a zero already. Clang actually emits a non canonical ordered check in isnormal as it is 


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

https://reviews.llvm.org/D139311



More information about the llvm-commits mailing list