Skip to content

Commit 0db408f

Browse files
committed
[HashRecognize] Address review
1 parent 08d6c2d commit 0db408f

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

llvm/lib/Analysis/HashRecognize.cpp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ using namespace SCEVPatternMatch;
7373

7474
#define DEBUG_TYPE "hash-recognize"
7575

76-
/// Checks if Loop \p L contains instructions unreachable \p Roots on the
77-
/// use-def chain.
76+
/// Checks that all instructions reachable from \p Roots on the use-def chain
77+
/// are contained within loop \p L, and that that are no stray instructions in
78+
/// the loop not visited by the use-def walk.
7879
static bool containsUnreachable(const Loop &L,
7980
ArrayRef<const Instruction *> Roots) {
8081
SmallPtrSet<const Instruction *, 16> Visited;
@@ -93,7 +94,6 @@ static bool containsUnreachable(const Loop &L,
9394
if (!L.contains(UI))
9495
return true;
9596
Worklist.push_back(UI);
96-
continue;
9797
}
9898
}
9999
}
@@ -157,17 +157,15 @@ struct RecurrenceInfo {
157157
/// compare are swapped). We check that the LHS is (ConditionalRecurrence.Phi
158158
/// [xor SimpleRecurrence.Phi]) in the big-endian case, and additionally check
159159
/// for an AND with one in the little-endian case. We then check AllowedByR
160-
/// against CheckAllowedByR, which is [0, smin) in the big-endian case, and [0,
161-
/// 1) in the little-endian case: CheckAllowedByR checks for
162-
/// significant-bit-clear, and this must be equal to ConditionalRecurrence.BO
163-
/// (which is the bit-shift, as already checked by isBigEndianBitShift) for
164-
/// well-formedness.
160+
/// against CheckAllowedByR, which is [0, smin) in the big-endian case, and
161+
/// against [0, 1) in the little-endian case: CheckAllowedByR checks for
162+
/// significant-bit-clear, and we match the corresponding arms of the select
163+
/// against bit-shift and bit-shift-and-xor-gen-poly.
165164
static bool
166165
isSignificantBitCheckWellFormed(const RecurrenceInfo &ConditionalRecurrence,
167166
const RecurrenceInfo &SimpleRecurrence,
168167
bool ByteOrderSwapped) {
169168
auto *SI = cast<SelectInst>(ConditionalRecurrence.Step);
170-
DataLayout DL = SI->getParent()->getDataLayout();
171169
CmpPredicate Pred;
172170
const Value *L;
173171
const APInt *R;
@@ -197,9 +195,11 @@ isSignificantBitCheckWellFormed(const RecurrenceInfo &ConditionalRecurrence,
197195

198196
BinaryOperator *BitShift = ConditionalRecurrence.BO;
199197
if (AllowedByR == CheckAllowedByR)
200-
return TV == BitShift;
198+
return TV == BitShift &&
199+
match(FV, m_c_Xor(m_Specific(BitShift), m_Constant()));
201200
if (AllowedByR.inverse() == CheckAllowedByR)
202-
return FV == BitShift;
201+
return FV == BitShift &&
202+
match(TV, m_c_Xor(m_Specific(BitShift), m_Constant()));
203203
return false;
204204
}
205205

@@ -219,8 +219,11 @@ isSignificantBitCheckWellFormed(const RecurrenceInfo &ConditionalRecurrence,
219219
/// %BO = binop %step, %rec
220220
///
221221
bool RecurrenceInfo::matchSimpleRecurrence(const PHINode *P) {
222-
Phi = P;
223-
return llvm::matchSimpleRecurrence(Phi, BO, Start, Step);
222+
if (llvm::matchSimpleRecurrence(P, BO, Start, Step)) {
223+
Phi = P;
224+
return true;
225+
}
226+
return false;
224227
}
225228

226229
/// Digs for a recurrence starting with \p V hitting the PHI node in a use-def

0 commit comments

Comments
 (0)