[llvm] [SelectionDAG] Add space-optimized forms of OPC_CheckComplexPat (PR #73310)

Wang Pengcheng via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 4 23:55:10 PST 2024


================
@@ -602,6 +601,7 @@ bool MatcherGen::EmitMatcherCode(unsigned Variant) {
 
     // Emit a CheckComplexPat operation, which does the match (aborting if it
     // fails) and pushes the matched operands onto the recorded nodes list.
+    CGP.increaseComplexPatternUsage(CP);
----------------
wangpc-pp wrote:

Thanks!
I have changed the implementation, now we don't need to record the usage when creating `XXXMatcher` nodes. Instead, we will do statistic just before emission (with a single pass iteration over the whole MatcherTable). I do this for two reasons:
* The previous implementation is too intrusive, and, as you see, we lost the const qualifier.
* There are some optimizations after creating `XXXMatcher` nodes and some nodes may be deleted, so we should do the statistic after optimizations.

The implementation is much easier to review now.

https://github.com/llvm/llvm-project/pull/73310


More information about the llvm-commits mailing list