[llvm] r327461 - [GISel]: Fix incorrect type used in Pattern Match for ICst
Aditya Nandakumar via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 13 16:21:13 PDT 2018
Author: aditya_nandakumar
Date: Tue Mar 13 16:21:13 2018
New Revision: 327461
URL: http://llvm.org/viewvc/llvm-project?rev=327461&view=rev
Log:
[GISel]: Fix incorrect type used in Pattern Match for ICst
getConstantVRegVal() returns int64_t but we use uint64_t.
Modified:
llvm/trunk/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
llvm/trunk/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp
Modified: llvm/trunk/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h?rev=327461&r1=327460&r2=327461&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h (original)
+++ llvm/trunk/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h Tue Mar 13 16:21:13 2018
@@ -43,8 +43,8 @@ inline OneUse_match<SubPat> m_OneUse(con
}
struct ConstantMatch {
- uint64_t &CR;
- ConstantMatch(uint64_t &C) : CR(C) {}
+ int64_t &CR;
+ ConstantMatch(int64_t &C) : CR(C) {}
bool match(const MachineRegisterInfo &MRI, unsigned Reg) {
if (auto MaybeCst = getConstantVRegVal(Reg, MRI)) {
CR = *MaybeCst;
@@ -54,7 +54,7 @@ struct ConstantMatch {
}
};
-inline ConstantMatch m_ICst(uint64_t &Cst) { return ConstantMatch(Cst); }
+inline ConstantMatch m_ICst(int64_t &Cst) { return ConstantMatch(Cst); }
// TODO: Rework this for different kinds of MachineOperand.
// Currently assumes the Src for a match is a register.
Modified: llvm/trunk/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp?rev=327461&r1=327460&r2=327461&view=diff
==============================================================================
--- llvm/trunk/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp (original)
+++ llvm/trunk/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp Tue Mar 13 16:21:13 2018
@@ -134,10 +134,10 @@ TEST(PatternMatchInstr, MatchIntConstant
MachineRegisterInfo &MRI = MF->getRegInfo();
B.setInsertPt(*EntryMBB, EntryMBB->end());
auto MIBCst = B.buildConstant(LLT::scalar(64), 42);
- uint64_t Cst;
+ int64_t Cst;
bool match = mi_match(MIBCst->getOperand(0).getReg(), MRI, m_ICst(Cst));
ASSERT_TRUE(match);
- ASSERT_EQ(Cst, (uint64_t)42);
+ ASSERT_EQ(Cst, 42);
}
TEST(PatternMatchInstr, MatchBinaryOp) {
@@ -189,11 +189,11 @@ TEST(PatternMatchInstr, MatchBinaryOp) {
auto MIBMul2 = B.buildMul(s64, Copies[0], B.buildConstant(s64, 42));
// Try to match MUL(Cst, Reg) on src of MUL(Reg, Cst) to validate
// commutativity.
- uint64_t Cst;
+ int64_t Cst;
match = mi_match(MIBMul2->getOperand(0).getReg(), MRI,
m_GMul(m_ICst(Cst), m_Reg(Src0)));
ASSERT_TRUE(match);
- ASSERT_EQ(Cst, (uint64_t)42);
+ ASSERT_EQ(Cst, 42);
ASSERT_EQ(Src0, Copies[0]);
// Make sure commutative doesn't work with something like SUB.
@@ -208,7 +208,7 @@ TEST(PatternMatchInstr, MatchBinaryOp) {
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(Cst, 42);
ASSERT_EQ(Src0, Copies[0]);
// Build AND %0, %1
More information about the llvm-commits
mailing list