69
69
#include " llvm/Support/KnownBits.h"
70
70
71
71
using namespace llvm ;
72
+ using namespace PatternMatch ;
73
+ using namespace SCEVPatternMatch ;
72
74
73
75
#define DEBUG_TYPE " hash-recognize"
74
76
@@ -173,14 +175,12 @@ KnownBits ValueEvolution::computeBinOp(const BinaryOperator *I,
173
175
// / Compute the KnownBits of Instruction \p I.
174
176
KnownBits ValueEvolution::computeInstr (const Instruction *I,
175
177
const KnownPhiMap &KnownPhis) {
176
- using namespace llvm ::PatternMatch;
177
-
178
178
unsigned BitWidth = I->getType ()->getScalarSizeInBits ();
179
179
180
180
// We look up in the map that contains the KnownBits of the PHI from the
181
181
// previous iteration.
182
182
if (const PHINode *P = dyn_cast<PHINode>(I))
183
- return KnownPhis.lookup_or (P, { BitWidth} );
183
+ return KnownPhis.lookup_or (P, BitWidth);
184
184
185
185
// Compute the KnownBits for a Select(Cmp()), forcing it to take the take the
186
186
// branch that is predicated on the (least|most)-significant-bit check.
@@ -196,7 +196,7 @@ KnownBits ValueEvolution::computeInstr(const Instruction *I,
196
196
auto RCR = ConstantRange::fromKnownBits (KnownR, false );
197
197
198
198
// We need to check LCR against [0, 2) in the little-endian case, because
199
- // the RCR check is too lax : it is simply [0, SMIN ).
199
+ // the RCR check is insufficient : it is simply [0, 1 ).
200
200
auto CheckLCR = ConstantRange (APInt::getZero (BitWidth), APInt (BitWidth, 2 ));
201
201
if (!ByteOrderSwapped && LCR != CheckLCR) {
202
202
ErrStr = " Bad LHS of significant-bit-check" ;
@@ -239,8 +239,6 @@ KnownBits ValueEvolution::computeInstr(const Instruction *I,
239
239
// / Compute the KnownBits of Value \p V.
240
240
KnownBits ValueEvolution::compute (const Value *V,
241
241
const KnownPhiMap &KnownPhis) {
242
- using namespace llvm ::PatternMatch;
243
-
244
242
unsigned BitWidth = V->getType ()->getScalarSizeInBits ();
245
243
246
244
const APInt *C;
@@ -262,7 +260,6 @@ ValueEvolution::computeEvolutions(ArrayRef<PhiStepPair> PhiEvolutions) {
262
260
for (unsigned I = 0 ; I < TripCount; ++I) {
263
261
AtIteration = I;
264
262
for (auto [Phi, Step] : PhiEvolutions) {
265
- // Check that the {top, bottom} I bits are zero, with the rest unknown.
266
263
KnownBits KnownAtIter = computeInstr (Step, KnownPhis);
267
264
if (KnownAtIter.getBitWidth () < I + 1 ) {
268
265
ErrStr = " Loop iterations exceed bitwidth of result" ;
@@ -271,8 +268,6 @@ ValueEvolution::computeEvolutions(ArrayRef<PhiStepPair> PhiEvolutions) {
271
268
KnownPhis.emplace_or_assign (Phi, KnownAtIter);
272
269
}
273
270
}
274
-
275
- // Return the final ComputedBits.
276
271
return KnownPhis;
277
272
}
278
273
@@ -282,8 +277,6 @@ static BinaryOperator *
282
277
digRecurrence (Instruction *V, const PHINode *P, const Loop &L,
283
278
const APInt *&ExtraConst,
284
279
Instruction::BinaryOps BOWithConstOpToMatch) {
285
- using namespace llvm ::PatternMatch;
286
-
287
280
SmallVector<Instruction *> Worklist;
288
281
Worklist.push_back (V);
289
282
while (!Worklist.empty ()) {
@@ -337,8 +330,6 @@ static bool matchConditionalRecurrence(
337
330
return false ;
338
331
339
332
for (unsigned Idx = 0 ; Idx != 2 ; ++Idx) {
340
- using namespace llvm ::PatternMatch;
341
-
342
333
Value *FoundStep = P->getIncomingValue (Idx);
343
334
Value *FoundStart = P->getIncomingValue (!Idx);
344
335
@@ -374,7 +365,7 @@ static bool matchConditionalRecurrence(
374
365
375
366
// / A structure that can hold either a Simple Recurrence or a Conditional
376
367
// / Recurrence. Note that in the case of a Simple Recurrence, Step is an operand
377
- // / of the BO, while in a Conditional Recurrence, Step is a SelectInst.
368
+ // / of the BO, while in a Conditional Recurrence, it is a SelectInst.
378
369
struct RecurrenceInfo {
379
370
PHINode *Phi;
380
371
BinaryOperator *BO;
@@ -452,7 +443,7 @@ static bool checkExtractBits(const KnownBits &Known, unsigned N,
452
443
unsigned BitPos = ByteOrderSwapped ? 0 : Known.getBitWidth () - N;
453
444
unsigned SwappedBitPos = ByteOrderSwapped ? N : 0 ;
454
445
455
- // If there are no other bits, check that the entire thing is a constant.
446
+ // Check that the entire thing is a constant.
456
447
if (N == Known.getBitWidth ())
457
448
return CheckFn (Known.extractBits (N, 0 ));
458
449
@@ -510,9 +501,9 @@ static bool arePHIsIntertwined(
510
501
511
502
// BOToMatch is usually XOR for CRC.
512
503
if (BOToMatch != Instruction::BinaryOpsEnd) {
513
- if (none_of (Worklist, [BOToMatch](const Instruction *I) {
504
+ if (count_if (Worklist, [BOToMatch](const Instruction *I) {
514
505
return I->getOpcode () == BOToMatch;
515
- }))
506
+ }) != 1 )
516
507
return false ;
517
508
}
518
509
@@ -539,8 +530,6 @@ static bool arePHIsIntertwined(
539
530
// equivalently shl/lshr. Return false when it is a UDiv, true when it is a Mul,
540
531
// and std::nullopt otherwise.
541
532
static std::optional<bool > isBigEndianBitShift (const SCEV *E) {
542
- using namespace llvm ::SCEVPatternMatch;
543
-
544
533
if (match (E, m_scev_UDiv (m_SCEV (), m_scev_SpecificInt (2 ))))
545
534
return false ;
546
535
if (match (E, m_scev_Mul (m_scev_SpecificInt (2 ), m_SCEV ())))
0 commit comments