Skip to content

Commit 61296b6

Browse files
committed
[HashRecognize] Add test with multiple blocks
1 parent 86904ee commit 61296b6

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

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

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,8 @@ exit: ; preds = %loop
404404
ret i16 %crc.next
405405
}
406406

407-
define i16 @not.crc.non.canonical.loop(i16 %crc.init) {
408-
; CHECK-LABEL: 'not.crc.non.canonical.loop'
407+
define i16 @not.crc.non.canonical.loop.countdown(i16 %crc.init) {
408+
; CHECK-LABEL: 'not.crc.non.canonical.loop.countdown'
409409
; CHECK-NEXT: Did not find a hash algorithm
410410
; CHECK-NEXT: Reason: Loop not in canonical form
411411
;
@@ -427,6 +427,35 @@ exit: ; preds = %loop
427427
ret i16 %crc.next
428428
}
429429

430+
define i16 @not.crc.non.canonical.loop.multiple.blocks(i16 %crc.init) {
431+
; CHECK-LABEL: 'not.crc.non.canonical.loop.multiple.blocks'
432+
; CHECK-NEXT: Did not find a hash algorithm
433+
; CHECK-NEXT: Reason: Loop not in canonical form
434+
;
435+
entry:
436+
br label %loop
437+
438+
loop: ; preds = %loop, %entry
439+
%iv = phi i32 [ 0, %entry ], [ %iv.next, %continue ]
440+
%crc = phi i16 [ %crc.init, %entry ], [ %crc.next, %continue ]
441+
%check.sb = icmp slt i16 %crc, 0
442+
%crc.shl = shl i16 %crc, 1
443+
br i1 %check.sb, label %xor, label %continue
444+
445+
xor:
446+
%crc.xor = xor i16 %crc.shl, 4129
447+
br label %continue
448+
449+
continue:
450+
%crc.next = phi i16 [ %crc.xor, %xor ], [ %crc.shl, %loop ]
451+
%iv.next = add nuw nsw i32 %iv, 1
452+
%exit.cond = icmp samesign eq i32 %iv, 7
453+
br i1 %exit.cond, label %exit, label %loop
454+
455+
exit: ; preds = %loop
456+
ret i16 %crc.next
457+
}
458+
430459
define i16 @not.crc.tc.limit(i16 %crc.init) {
431460
; CHECK-LABEL: 'not.crc.tc.limit'
432461
; CHECK-NEXT: Did not find a hash algorithm

0 commit comments

Comments
 (0)