return BinaryOp_match<LHS, RHS, TargetOpcode::G_FADD, true>(L, R);
}
+template <typename LHS, typename RHS>
+inline BinaryOp_match<LHS, RHS, TargetOpcode::G_FMUL, true>
+m_GFMul(const LHS &L, const RHS &R) {
+ return BinaryOp_match<LHS, RHS, TargetOpcode::G_FMUL, true>(L, R);
+}
+
// Helper for unary instructions (G_[ZSA]EXT/G_TRUNC) etc
template <typename SrcTy, unsigned Opcode> struct UnaryOp_match {
SrcTy L;
match = mi_match(MIBSub->getOperand(0).getReg(), MRI,
m_GSub(m_ICst(Cst), m_Reg(Src0)));
ASSERT_FALSE(match);
+
+ auto MIBFMul = B.buildInstr(TargetOpcode::G_FMUL, s64, Copies[0],
+ B.buildConstant(s64, 42));
+ // Match and test commutativity for FMUL.
+ match = mi_match(MIBFMul->getOperand(0).getReg(), MRI,
+ m_GFMul(m_ICst(Cst), m_Reg(Src0)));
+ ASSERT_TRUE(match);
+ ASSERT_EQ(Cst, (uint64_t)42);
+ ASSERT_EQ(Src0, Copies[0]);
}
TEST(PatternMatchInstr, MatchExtendsTrunc) {