Skip to content

Conversation

asl
Copy link
Contributor

@asl asl commented May 18, 2025

  • Add node pattern matching implementation similar to LLVM's IR pattern matching:
    • More flexible & generic than present pattern matching, could be further extended if necessary
    • Can optionally bind nodes in the pattern to local variables
    • Can match types, can perform deferred matching (e.g. refine the match further on)
  • Switch reassociation and strength reduction to this new implementation
  • Extend reassociation (and document its limitations)
  • Add couple more strength reduction patterns

@asl asl requested review from grg, vlstill, ChrisDodd and fruffy May 18, 2025 20:06
@fruffy fruffy added the core Topics concerning the core segments of the compiler (frontend, midend, parser) label May 18, 2025
Signed-off-by: Anton Korobeynikov <[email protected]>
Signed-off-by: Anton Korobeynikov <[email protected]>
const IR::Constant *c1, *c2;
const IR::Expression *e;
if (match(root,
m_BinOp(m_AllOf(m_BinOp(lhs), m_BinOp(m_Expr(e), m_Constant(c1))), m_Constant(c2))) &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems far inferior to the IR::Pattern matching, which is much simpler and clearer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will you please be more specific? How I can e.g. match if operand has particular type in IR::Pattern? Or check if two operands are the same? etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Topics concerning the core segments of the compiler (frontend, midend, parser)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants