[llvm] Add remaining patterns for floating-point flag matches (PR #173912)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 10 02:36:30 PST 2026
================
@@ -81,19 +82,76 @@ template <typename T> inline OneUse_match<T> m_OneUse(const T &SubPattern) {
return SubPattern;
}
-template <typename SubPattern_t> struct AllowReassoc_match {
+template <typename SubPattern_t, int Flag> struct AllowFmf_match {
SubPattern_t SubPattern;
-
- AllowReassoc_match(const SubPattern_t &SP) : SubPattern(SP) {}
+ FastMathFlags FMF;
+
+ AllowFmf_match(const SubPattern_t &SP) : SubPattern(SP) {
+ if (Flag == FastMathFlags::AllowReassoc)
+ FMF.setAllowReassoc();
+ if (Flag == FastMathFlags::AllowReciprocal)
+ FMF.setAllowReciprocal();
+ if (Flag == FastMathFlags::AllowContract)
+ FMF.setAllowContract();
+ if (Flag == FastMathFlags::ApproxFunc)
+ FMF.setApproxFunc();
+ if (Flag == FastMathFlags::NoNaNs)
+ FMF.setNoNaNs();
+ if (Flag == FastMathFlags::NoInfs)
+ FMF.setNoInfs();
+ if (Flag == FastMathFlags::NoSignedZeros)
+ FMF.setNoSignedZeros();
----------------
nikic wrote:
This looks rather awkward -- is there some particular reason why we don't allow initializing FastMathFlags directly from a flag value?
https://github.com/llvm/llvm-project/pull/173912
More information about the llvm-commits
mailing list