@@ -71,7 +71,7 @@ TEST_F(PatternMatchTest, SpecificIntEQ) {
71
71
72
72
Value *Zero = ConstantInt::get (IntTy, 0 );
73
73
Value *One = ConstantInt::get (IntTy, 1 );
74
- Value *NegOne = ConstantInt::get (IntTy, - 1 );
74
+ Value *NegOne = Constant::getAllOnesValue (IntTy);
75
75
76
76
EXPECT_TRUE (
77
77
m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_EQ, APInt (BitWidth, 0 ))
@@ -93,15 +93,15 @@ TEST_F(PatternMatchTest, SpecificIntEQ) {
93
93
m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_EQ, APInt (BitWidth, 1 ))
94
94
.match (NegOne));
95
95
96
- EXPECT_FALSE (
97
- m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_EQ, APInt (BitWidth, - 1 ))
98
- .match (Zero));
99
- EXPECT_FALSE (
100
- m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_EQ, APInt (BitWidth, - 1 ))
101
- .match (One));
102
- EXPECT_TRUE (
103
- m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_EQ, APInt (BitWidth, - 1 ))
104
- .match (NegOne));
96
+ EXPECT_FALSE (m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_EQ,
97
+ APInt::getAllOnes (BitWidth))
98
+ .match (Zero));
99
+ EXPECT_FALSE (m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_EQ,
100
+ APInt::getAllOnes (BitWidth))
101
+ .match (One));
102
+ EXPECT_TRUE (m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_EQ,
103
+ APInt::getAllOnes (BitWidth))
104
+ .match (NegOne));
105
105
}
106
106
107
107
TEST_F (PatternMatchTest, SpecificIntNE) {
@@ -110,7 +110,7 @@ TEST_F(PatternMatchTest, SpecificIntNE) {
110
110
111
111
Value *Zero = ConstantInt::get (IntTy, 0 );
112
112
Value *One = ConstantInt::get (IntTy, 1 );
113
- Value *NegOne = ConstantInt::get (IntTy, - 1 );
113
+ Value *NegOne = Constant::getAllOnesValue (IntTy);
114
114
115
115
EXPECT_FALSE (
116
116
m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_NE, APInt (BitWidth, 0 ))
@@ -132,15 +132,15 @@ TEST_F(PatternMatchTest, SpecificIntNE) {
132
132
m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_NE, APInt (BitWidth, 1 ))
133
133
.match (NegOne));
134
134
135
- EXPECT_TRUE (
136
- m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_NE, APInt (BitWidth, - 1 ))
137
- .match (Zero));
138
- EXPECT_TRUE (
139
- m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_NE, APInt (BitWidth, - 1 ))
140
- .match (One));
141
- EXPECT_FALSE (
142
- m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_NE, APInt (BitWidth, - 1 ))
143
- .match (NegOne));
135
+ EXPECT_TRUE (m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_NE,
136
+ APInt::getAllOnes (BitWidth))
137
+ .match (Zero));
138
+ EXPECT_TRUE (m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_NE,
139
+ APInt::getAllOnes (BitWidth))
140
+ .match (One));
141
+ EXPECT_FALSE (m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_NE,
142
+ APInt::getAllOnes (BitWidth))
143
+ .match (NegOne));
144
144
}
145
145
146
146
TEST_F (PatternMatchTest, SpecificIntUGT) {
@@ -149,7 +149,7 @@ TEST_F(PatternMatchTest, SpecificIntUGT) {
149
149
150
150
Value *Zero = ConstantInt::get (IntTy, 0 );
151
151
Value *One = ConstantInt::get (IntTy, 1 );
152
- Value *NegOne = ConstantInt::get (IntTy, - 1 );
152
+ Value *NegOne = Constant::getAllOnesValue (IntTy);
153
153
154
154
EXPECT_FALSE (
155
155
m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_UGT, APInt (BitWidth, 0 ))
@@ -171,23 +171,23 @@ TEST_F(PatternMatchTest, SpecificIntUGT) {
171
171
m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_UGT, APInt (BitWidth, 1 ))
172
172
.match (NegOne));
173
173
174
- EXPECT_FALSE (
175
- m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_UGT, APInt (BitWidth, - 1 ))
176
- .match (Zero));
177
- EXPECT_FALSE (
178
- m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_UGT, APInt (BitWidth, - 1 ))
179
- .match (One));
180
- EXPECT_FALSE (
181
- m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_UGT, APInt (BitWidth, - 1 ))
182
- .match (NegOne));
174
+ EXPECT_FALSE (m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_UGT,
175
+ APInt::getAllOnes (BitWidth))
176
+ .match (Zero));
177
+ EXPECT_FALSE (m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_UGT,
178
+ APInt::getAllOnes (BitWidth))
179
+ .match (One));
180
+ EXPECT_FALSE (m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_UGT,
181
+ APInt::getAllOnes (BitWidth))
182
+ .match (NegOne));
183
183
}
184
184
185
185
TEST_F (PatternMatchTest, SignbitZeroChecks) {
186
186
Type *IntTy = IRB.getInt32Ty ();
187
187
188
188
Value *Zero = ConstantInt::get (IntTy, 0 );
189
189
Value *One = ConstantInt::get (IntTy, 1 );
190
- Value *NegOne = ConstantInt::get (IntTy, - 1 );
190
+ Value *NegOne = Constant::getAllOnesValue (IntTy);
191
191
192
192
EXPECT_TRUE (m_Negative ().match (NegOne));
193
193
EXPECT_FALSE (m_NonNegative ().match (NegOne));
@@ -211,7 +211,7 @@ TEST_F(PatternMatchTest, SpecificIntUGE) {
211
211
212
212
Value *Zero = ConstantInt::get (IntTy, 0 );
213
213
Value *One = ConstantInt::get (IntTy, 1 );
214
- Value *NegOne = ConstantInt::get (IntTy, - 1 );
214
+ Value *NegOne = Constant::getAllOnesValue (IntTy);
215
215
216
216
EXPECT_TRUE (
217
217
m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_UGE, APInt (BitWidth, 0 ))
@@ -233,15 +233,15 @@ TEST_F(PatternMatchTest, SpecificIntUGE) {
233
233
m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_UGE, APInt (BitWidth, 1 ))
234
234
.match (NegOne));
235
235
236
- EXPECT_FALSE (
237
- m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_UGE, APInt (BitWidth, - 1 ))
238
- .match (Zero));
239
- EXPECT_FALSE (
240
- m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_UGE, APInt (BitWidth, - 1 ))
241
- .match (One));
242
- EXPECT_TRUE (
243
- m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_UGE, APInt (BitWidth, - 1 ))
244
- .match (NegOne));
236
+ EXPECT_FALSE (m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_UGE,
237
+ APInt::getAllOnes (BitWidth))
238
+ .match (Zero));
239
+ EXPECT_FALSE (m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_UGE,
240
+ APInt::getAllOnes (BitWidth))
241
+ .match (One));
242
+ EXPECT_TRUE (m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_UGE,
243
+ APInt::getAllOnes (BitWidth))
244
+ .match (NegOne));
245
245
}
246
246
247
247
TEST_F (PatternMatchTest, SpecificIntULT) {
@@ -250,7 +250,7 @@ TEST_F(PatternMatchTest, SpecificIntULT) {
250
250
251
251
Value *Zero = ConstantInt::get (IntTy, 0 );
252
252
Value *One = ConstantInt::get (IntTy, 1 );
253
- Value *NegOne = ConstantInt::get (IntTy, - 1 );
253
+ Value *NegOne = Constant::getAllOnesValue (IntTy);
254
254
255
255
EXPECT_FALSE (
256
256
m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_ULT, APInt (BitWidth, 0 ))
@@ -272,15 +272,15 @@ TEST_F(PatternMatchTest, SpecificIntULT) {
272
272
m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_ULT, APInt (BitWidth, 1 ))
273
273
.match (NegOne));
274
274
275
- EXPECT_TRUE (
276
- m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_ULT, APInt (BitWidth, - 1 ))
277
- .match (Zero));
278
- EXPECT_TRUE (
279
- m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_ULT, APInt (BitWidth, - 1 ))
280
- .match (One));
281
- EXPECT_FALSE (
282
- m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_ULT, APInt (BitWidth, - 1 ))
283
- .match (NegOne));
275
+ EXPECT_TRUE (m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_ULT,
276
+ APInt::getAllOnes (BitWidth))
277
+ .match (Zero));
278
+ EXPECT_TRUE (m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_ULT,
279
+ APInt::getAllOnes (BitWidth))
280
+ .match (One));
281
+ EXPECT_FALSE (m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_ULT,
282
+ APInt::getAllOnes (BitWidth))
283
+ .match (NegOne));
284
284
}
285
285
286
286
TEST_F (PatternMatchTest, SpecificIntULE) {
@@ -289,7 +289,7 @@ TEST_F(PatternMatchTest, SpecificIntULE) {
289
289
290
290
Value *Zero = ConstantInt::get (IntTy, 0 );
291
291
Value *One = ConstantInt::get (IntTy, 1 );
292
- Value *NegOne = ConstantInt::get (IntTy, - 1 );
292
+ Value *NegOne = Constant::getAllOnesValue (IntTy);
293
293
294
294
EXPECT_TRUE (
295
295
m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_ULE, APInt (BitWidth, 0 ))
@@ -311,15 +311,15 @@ TEST_F(PatternMatchTest, SpecificIntULE) {
311
311
m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_ULE, APInt (BitWidth, 1 ))
312
312
.match (NegOne));
313
313
314
- EXPECT_TRUE (
315
- m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_ULE, APInt (BitWidth, - 1 ))
316
- .match (Zero));
317
- EXPECT_TRUE (
318
- m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_ULE, APInt (BitWidth, - 1 ))
319
- .match (One));
320
- EXPECT_TRUE (
321
- m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_ULE, APInt (BitWidth, - 1 ))
322
- .match (NegOne));
314
+ EXPECT_TRUE (m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_ULE,
315
+ APInt::getAllOnes (BitWidth))
316
+ .match (Zero));
317
+ EXPECT_TRUE (m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_ULE,
318
+ APInt::getAllOnes (BitWidth))
319
+ .match (One));
320
+ EXPECT_TRUE (m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_ULE,
321
+ APInt::getAllOnes (BitWidth))
322
+ .match (NegOne));
323
323
}
324
324
325
325
TEST_F (PatternMatchTest, SpecificIntSGT) {
@@ -328,7 +328,7 @@ TEST_F(PatternMatchTest, SpecificIntSGT) {
328
328
329
329
Value *Zero = ConstantInt::get (IntTy, 0 );
330
330
Value *One = ConstantInt::get (IntTy, 1 );
331
- Value *NegOne = ConstantInt::get (IntTy, - 1 );
331
+ Value *NegOne = Constant::getAllOnesValue (IntTy);
332
332
333
333
EXPECT_FALSE (
334
334
m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_SGT, APInt (BitWidth, 0 ))
@@ -350,15 +350,15 @@ TEST_F(PatternMatchTest, SpecificIntSGT) {
350
350
m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_SGT, APInt (BitWidth, 1 ))
351
351
.match (NegOne));
352
352
353
- EXPECT_TRUE (
354
- m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_SGT, APInt (BitWidth, - 1 ))
355
- .match (Zero));
356
- EXPECT_TRUE (
357
- m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_SGT, APInt (BitWidth, - 1 ))
358
- .match (One));
359
- EXPECT_FALSE (
360
- m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_SGT, APInt (BitWidth, - 1 ))
361
- .match (NegOne));
353
+ EXPECT_TRUE (m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_SGT,
354
+ APInt::getAllOnes (BitWidth))
355
+ .match (Zero));
356
+ EXPECT_TRUE (m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_SGT,
357
+ APInt::getAllOnes (BitWidth))
358
+ .match (One));
359
+ EXPECT_FALSE (m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_SGT,
360
+ APInt::getAllOnes (BitWidth))
361
+ .match (NegOne));
362
362
}
363
363
364
364
TEST_F (PatternMatchTest, SpecificIntSGE) {
@@ -367,7 +367,7 @@ TEST_F(PatternMatchTest, SpecificIntSGE) {
367
367
368
368
Value *Zero = ConstantInt::get (IntTy, 0 );
369
369
Value *One = ConstantInt::get (IntTy, 1 );
370
- Value *NegOne = ConstantInt::get (IntTy, - 1 );
370
+ Value *NegOne = Constant::getAllOnesValue (IntTy);
371
371
372
372
EXPECT_TRUE (
373
373
m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_SGE, APInt (BitWidth, 0 ))
@@ -389,15 +389,15 @@ TEST_F(PatternMatchTest, SpecificIntSGE) {
389
389
m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_SGE, APInt (BitWidth, 1 ))
390
390
.match (NegOne));
391
391
392
- EXPECT_TRUE (
393
- m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_SGE, APInt (BitWidth, - 1 ))
394
- .match (Zero));
395
- EXPECT_TRUE (
396
- m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_SGE, APInt (BitWidth, - 1 ))
397
- .match (One));
398
- EXPECT_TRUE (
399
- m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_SGE, APInt (BitWidth, - 1 ))
400
- .match (NegOne));
392
+ EXPECT_TRUE (m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_SGE,
393
+ APInt::getAllOnes (BitWidth))
394
+ .match (Zero));
395
+ EXPECT_TRUE (m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_SGE,
396
+ APInt::getAllOnes (BitWidth))
397
+ .match (One));
398
+ EXPECT_TRUE (m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_SGE,
399
+ APInt::getAllOnes (BitWidth))
400
+ .match (NegOne));
401
401
}
402
402
403
403
TEST_F (PatternMatchTest, SpecificIntSLT) {
@@ -406,7 +406,7 @@ TEST_F(PatternMatchTest, SpecificIntSLT) {
406
406
407
407
Value *Zero = ConstantInt::get (IntTy, 0 );
408
408
Value *One = ConstantInt::get (IntTy, 1 );
409
- Value *NegOne = ConstantInt::get (IntTy, - 1 );
409
+ Value *NegOne = Constant::getAllOnesValue (IntTy);
410
410
411
411
EXPECT_FALSE (
412
412
m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_SLT, APInt (BitWidth, 0 ))
@@ -428,15 +428,15 @@ TEST_F(PatternMatchTest, SpecificIntSLT) {
428
428
m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_SLT, APInt (BitWidth, 1 ))
429
429
.match (NegOne));
430
430
431
- EXPECT_FALSE (
432
- m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_SLT, APInt (BitWidth, - 1 ))
433
- .match (Zero));
434
- EXPECT_FALSE (
435
- m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_SLT, APInt (BitWidth, - 1 ))
436
- .match (One));
437
- EXPECT_FALSE (
438
- m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_SLT, APInt (BitWidth, - 1 ))
439
- .match (NegOne));
431
+ EXPECT_FALSE (m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_SLT,
432
+ APInt::getAllOnes (BitWidth))
433
+ .match (Zero));
434
+ EXPECT_FALSE (m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_SLT,
435
+ APInt::getAllOnes (BitWidth))
436
+ .match (One));
437
+ EXPECT_FALSE (m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_SLT,
438
+ APInt::getAllOnes (BitWidth))
439
+ .match (NegOne));
440
440
}
441
441
442
442
TEST_F (PatternMatchTest, SpecificIntSLE) {
@@ -445,7 +445,7 @@ TEST_F(PatternMatchTest, SpecificIntSLE) {
445
445
446
446
Value *Zero = ConstantInt::get (IntTy, 0 );
447
447
Value *One = ConstantInt::get (IntTy, 1 );
448
- Value *NegOne = ConstantInt::get (IntTy, - 1 );
448
+ Value *NegOne = Constant::getAllOnesValue (IntTy);
449
449
450
450
EXPECT_TRUE (
451
451
m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_SLE, APInt (BitWidth, 0 ))
@@ -467,15 +467,15 @@ TEST_F(PatternMatchTest, SpecificIntSLE) {
467
467
m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_SLE, APInt (BitWidth, 1 ))
468
468
.match (NegOne));
469
469
470
- EXPECT_FALSE (
471
- m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_SLE, APInt (BitWidth, - 1 ))
472
- .match (Zero));
473
- EXPECT_FALSE (
474
- m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_SLE, APInt (BitWidth, - 1 ))
475
- .match (One));
476
- EXPECT_TRUE (
477
- m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_SLE, APInt (BitWidth, - 1 ))
478
- .match (NegOne));
470
+ EXPECT_FALSE (m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_SLE,
471
+ APInt::getAllOnes (BitWidth))
472
+ .match (Zero));
473
+ EXPECT_FALSE (m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_SLE,
474
+ APInt::getAllOnes (BitWidth))
475
+ .match (One));
476
+ EXPECT_TRUE (m_SpecificInt_ICMP (ICmpInst::Predicate::ICMP_SLE,
477
+ APInt::getAllOnes (BitWidth))
478
+ .match (NegOne));
479
479
}
480
480
481
481
TEST_F (PatternMatchTest, Unless) {
0 commit comments