[PATCH] D33185: Fix m_[Ord|Unord][FMin|FMax] matchers to correctly match ordering.

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 12 09:39:52 PDT 2017


spatel accepted this revision.
spatel added a comment.
This revision is now accepted and ready to land.

In https://reviews.llvm.org/D33185#778060, @a.elovikov wrote:

> In https://reviews.llvm.org/D33185#778032, @spatel wrote:
>
> > Sorry for the delay. Can this bug be exposed with an IR transform or a codegen test?
>
>
> I am not aware of such cases. I've faced that when working on https://reviews.llvm.org/D33186 but later decided to work with fast math only there. But I believe that this is still useful to fix. At least someone else won't be surprised by it.


Agreed - we need to fix the bug. LGTM. Please see inline comments too for some cleanup.



================
Comment at: llvm/include/llvm/IR/PatternMatch.h:1118
 ///
 ///                         max(L, R)  iff L and R are not NaN
 ///  m_OrdFMin(L, R) =      R          iff L or R are NaN
----------------
max(L, R) --> min(L, R)


================
Comment at: llvm/include/llvm/IR/PatternMatch.h:1134
 ///                         max(L, R)  iff L and R are not NaN
 ///  m_UnordFMin(L, R) =    L          iff L or R are NaN
 template <typename LHS, typename RHS>
----------------
m_UnordFMin(L, R) --> m_UnordFMax(L, R)


================
Comment at: llvm/include/llvm/IR/PatternMatch.h:1187-1200
 /// \brief Match an 'unordered' floating point minimum function.
 /// Floating point has one special value 'NaN'. Therefore, there is no total
 /// order. However, if we can ignore the 'NaN' value (for example, because of a
 /// 'no-nans-float-math' flag) a combination of a fcmp and select has 'minimum'
 /// semantics. In the presence of 'NaN' we have to preserve the original
 /// select(fcmp(ult/le, L, R), L, R) semantics matched by this predicate.
 ///
----------------
This should be moved up with the related fmin/fmax templates.


================
Comment at: llvm/include/llvm/IR/PatternMatch.h:1194
 ///
 ///                          max(L, R)  iff L and R are not NaN
 ///  m_UnordFMin(L, R) =     L          iff L or R are NaN
----------------
max(L, R) --> min(L, R)


https://reviews.llvm.org/D33185





More information about the llvm-commits mailing list