llvm.org GIT mirror llvm / 2477556
[GISel]: Add Pattern Matcher for G_FMUL. https://reviews.llvm.org/D43206 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@325044 91177308-0d34-0410-b5e6-96231b3b80d8 Aditya Nandakumar 2 years ago
2 changed file(s) with 15 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
201201 return BinaryOp_match(L, R);
202202 }
203203
204 template
205 inline BinaryOp_match
206 m_GFMul(const LHS &L, const RHS &R) {
207 return BinaryOp_match(L, R);
208 }
209
204210 // Helper for unary instructions (G_[ZSA]EXT/G_TRUNC) etc
205211 template struct UnaryOp_match {
206212 SrcTy L;
200200 match = mi_match(MIBSub->getOperand(0).getReg(), MRI,
201201 m_GSub(m_ICst(Cst), m_Reg(Src0)));
202202 ASSERT_FALSE(match);
203
204 auto MIBFMul = B.buildInstr(TargetOpcode::G_FMUL, s64, Copies[0],
205 B.buildConstant(s64, 42));
206 // Match and test commutativity for FMUL.
207 match = mi_match(MIBFMul->getOperand(0).getReg(), MRI,
208 m_GFMul(m_ICst(Cst), m_Reg(Src0)));
209 ASSERT_TRUE(match);
210 ASSERT_EQ(Cst, (uint64_t)42);
211 ASSERT_EQ(Src0, Copies[0]);
203212 }
204213
205214 TEST(PatternMatchInstr, MatchExtendsTrunc) {