Skip to content

Commit 9d95557

Browse files
committed
[GlobalISel] Add LLT::operator!=().
llvm-svn: 277162
1 parent 8292bdf commit 9d95557

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

llvm/include/llvm/CodeGen/LowLevelType.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,13 @@ class LLT {
169169

170170
void print(raw_ostream &OS) const;
171171

172-
bool operator ==(const LLT &RHS) const {
172+
bool operator==(const LLT &RHS) const {
173173
return Kind == RHS.Kind && SizeOrAddrSpace == RHS.SizeOrAddrSpace &&
174174
NumElements == RHS.NumElements;
175175
}
176176

177+
bool operator!=(const LLT &RHS) const { return !(*this == RHS); }
178+
177179
friend struct DenseMapInfo<LLT>;
178180
private:
179181
unsigned SizeOrAddrSpace;

llvm/unittests/CodeGen/LowLevelTypeTest.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ TEST(LowLevelTypeTest, Scalar) {
6060

6161
// Test equality operators.
6262
EXPECT_TRUE(Ty == Ty);
63+
EXPECT_FALSE(Ty != Ty);
64+
65+
EXPECT_NE(Ty, DoubleTy);
6366

6467
// Test Type->LLT conversion.
6568
const Type *IRTy = IntegerType::get(C, S);
@@ -141,6 +144,15 @@ TEST(LowLevelTypeTest, Vector) {
141144

142145
// Test equality operators.
143146
EXPECT_TRUE(VTy == VTy);
147+
EXPECT_FALSE(VTy != VTy);
148+
149+
// Test inequality operators on..
150+
// ..different kind.
151+
EXPECT_NE(VTy, STy);
152+
// ..different #elts.
153+
EXPECT_NE(VTy, DoubleEltTy);
154+
// ..different scalar size.
155+
EXPECT_NE(VTy, DoubleSzTy);
144156

145157
// Test Type->LLT conversion.
146158
Type *IRSTy = IntegerType::get(C, S);
@@ -169,6 +181,7 @@ TEST(LowLevelTypeTest, Pointer) {
169181

170182
// Test equality operators.
171183
EXPECT_TRUE(Ty == Ty);
184+
EXPECT_FALSE(Ty != Ty);
172185

173186
// Test Type->LLT conversion.
174187
const Type *IRTy = PointerType::get(IntegerType::get(C, 8), AS);

0 commit comments

Comments
 (0)