[llvm] Add remaining patterns for floating-point flag matches (PR #173912)
Mikołaj Piróg via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 13 13:26:06 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();
----------------
mikolaj-pirog wrote:
I'm not aware of particular reasons why is that -- the ctor that takes int is private. Maybe because we can't control if the value of the int makes sense for FastMathFlags? I think it should be public regardless + have an assert to check if the flag value makes sense. What do you think?
https://github.com/llvm/llvm-project/pull/173912
More information about the llvm-commits
mailing list