Add matchers that support commutative and non-commutative binary opcodes.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Simplify tests that fail because of non-binary instruction (match register instead of m_ICst) since they fail when number of def/use operands is checked. Update commit message.
I'm not sure the "AnyBinaryOp" versions are really needed for anything -- see https://reviews.llvm.org/D90050#inline-955365.
As for BinaryOpWithOpcode_match, couldn't you just change the existing BinaryOp_match to take the opcode as a regular argument instead of a template argument? (Are you worried about making it slower? Hopefully with proper inlining there would be no codegen difference at all.)
Removed matchers that don't check opcode.
My guess is that this was originally done as a equivalent of IR/PatternMatch.h.
Thus i also added AnyBinaryOp_match alongside with the version that checks opcode which i originally wanted(named BinaryOpc_match here).
I thought that AnyBinaryOp_match would be useful when we know opcode already so we avoid checking it again, but turns out that at the moment this is not that useful.
I would prefer to leave existing code with opcodes as template arguments like in IR/PatternMatch.h and add new matcher that has opcode as an regular argument instead. m_Add ect. are meant to have templated opcode and changing it to regular opcode argument almost guaranteed results in a same thing but brings no improvement.
I would prefer to leave existing code with opcodes as template arguments like in IR/PatternMatch.h and add new matcher that has opcode as an regular argument instead.
Fair enough, if no-one else objects to that approach.
Commutative?