forked from OSchip/llvm-project
[GISel]: Add Pattern Matcher for G_FMUL.
https://reviews.llvm.org/D43206 llvm-svn: 325044
This commit is contained in:
parent
413495fbe7
commit
6250b18831
|
@ -202,6 +202,12 @@ m_GFAdd(const LHS &L, const RHS &R) {
|
|||
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;
|
||||
|
|
|
@ -201,6 +201,15 @@ TEST(PatternMatchInstr, MatchBinaryOp) {
|
|||
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) {
|
||||
|
|
Loading…
Reference in New Issue