Skip to content

Commit ee312fc

Browse files
authored
[HashRecognize] Strip excess-TC check (#157479)
Checking if trip-count exceeds 256 is no longer necessary, as we have moved away from KnownBits computations to pattern-matching, which is very cheap and independent of TC.
1 parent 3beec2f commit ee312fc

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

llvm/lib/Analysis/HashRecognize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ std::variant<PolynomialInfo, StringRef> HashRecognize::recognizeCRC() const {
446446
if (!Latch || !Exit || !IndVar || L.getNumBlocks() != 1)
447447
return "Loop not in canonical form";
448448
unsigned TC = SE.getSmallConstantTripCount(&L);
449-
if (!TC || TC > 256 || TC % 8)
449+
if (!TC || TC % 8)
450450
return "Unable to find a small constant byte-multiple trip count";
451451

452452
auto R = getRecurrences(Latch, IndVar, L);

llvm/test/Analysis/HashRecognize/cyclic-redundancy-check.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -574,10 +574,10 @@ exit: ; preds = %loop
574574
ret i16 %crc.next
575575
}
576576

577-
define i16 @not.crc.tc.limit(i16 %crc.init) {
578-
; CHECK-LABEL: 'not.crc.tc.limit'
577+
define i16 @not.crc.tc.exceeds.data.bw(i16 %crc.init) {
578+
; CHECK-LABEL: 'not.crc.tc.exceeds.data.bw'
579579
; CHECK-NEXT: Did not find a hash algorithm
580-
; CHECK-NEXT: Reason: Unable to find a small constant byte-multiple trip count
580+
; CHECK-NEXT: Reason: Loop iterations exceed bitwidth of data
581581
;
582582
entry:
583583
br label %loop
@@ -590,7 +590,7 @@ loop: ; preds = %loop, %entry
590590
%check.sb = icmp slt i16 %crc, 0
591591
%crc.next = select i1 %check.sb, i16 %crc.xor, i16 %crc.shl
592592
%iv.next = add nuw nsw i32 %iv, 1
593-
%exit.cond = icmp samesign ult i32 %iv, 512
593+
%exit.cond = icmp samesign ult i32 %iv, 511
594594
br i1 %exit.cond, label %loop, label %exit
595595

596596
exit: ; preds = %loop

0 commit comments

Comments
 (0)