Skip to content

Commit

Permalink
Fix according to comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lialan committed Feb 4, 2025
1 parent 70862e7 commit 11c4ae0
Showing 1 changed file with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ class PolynomialApproximationPass final
void runOnOperation() override {

using PatternFunction = llvm::function_ref<void(RewritePatternSet &)>;

auto populateErfPattern = [&](RewritePatternSet &patterns) {
if (clNativeMathPrecision) {
patterns.add<math::ErfPolynomialApproximation>(&getContext());
} else {
populateExpandExp2FPattern(patterns);
populateMathPolynomialApproximationPatterns(patterns);
populateExpandRoundEvenPattern(patterns);
}
};

// Order matters here.
llvm::SmallVector<std::pair<StringRef, PatternFunction>> patternMap = {
{"tan", populateExpandTanPattern},
Expand All @@ -45,16 +56,7 @@ class PolynomialApproximationPass final
{"atanh", populateExpandAtanhPattern},
{"powf", populateExpandPowFPattern},
{"fpowi", populateExpandFPowIPattern},
{"erf",
[&](RewritePatternSet &patterns) {
if (clNativeMathPrecision) {
patterns.add<math::ErfPolynomialApproximation>(&getContext());
} else {
populateExpandExp2FPattern(patterns);
populateMathPolynomialApproximationPatterns(patterns);
populateExpandRoundEvenPattern(patterns);
}
}},
{"erf", populateErfPattern},
};

RewritePatternSet mathPatterns(&getContext());
Expand Down

0 comments on commit 11c4ae0

Please sign in to comment.