@@ -146,8 +146,28 @@ exit: ; preds = %loop
146
146
147
147
define i8 @crc8.le.tc16 (i16 %msg , i8 %checksum ) {
148
148
; CHECK-LABEL: 'crc8.le.tc16'
149
- ; CHECK-NEXT: Did not find a hash algorithm
150
- ; CHECK-NEXT: Reason: Loop iterations exceed bitwidth of result
149
+ ; CHECK-NEXT: Found little-endian CRC-8 loop with trip count 16
150
+ ; CHECK-NEXT: Initial CRC: i8 %checksum
151
+ ; CHECK-NEXT: Generating polynomial: 29
152
+ ; CHECK-NEXT: Computed CRC: %crc.next = select i1 %check.sb, i8 %crc.lshr, i8 %crc.xor
153
+ ; CHECK-NEXT: Auxiliary data: i16 %msg
154
+ ; CHECK-NEXT: Computed CRC lookup table:
155
+ ; CHECK-NEXT: 0 9 18 27 31 22 13 4 5 12 23 30 26 19 8 1
156
+ ; CHECK-NEXT: 10 3 24 17 21 28 7 14 15 6 29 20 16 25 2 11
157
+ ; CHECK-NEXT: 20 29 6 15 11 2 25 16 17 24 3 10 14 7 28 21
158
+ ; CHECK-NEXT: 30 23 12 5 1 8 19 26 27 18 9 0 4 13 22 31
159
+ ; CHECK-NEXT: 19 26 1 8 12 5 30 23 22 31 4 13 9 0 27 18
160
+ ; CHECK-NEXT: 25 16 11 2 6 15 20 29 28 21 14 7 3 10 17 24
161
+ ; CHECK-NEXT: 7 14 21 28 24 17 10 3 2 11 16 25 29 20 15 6
162
+ ; CHECK-NEXT: 13 4 31 22 18 27 0 9 8 1 26 19 23 30 5 12
163
+ ; CHECK-NEXT: 29 20 15 6 2 11 16 25 24 17 10 3 7 14 21 28
164
+ ; CHECK-NEXT: 23 30 5 12 8 1 26 19 18 27 0 9 13 4 31 22
165
+ ; CHECK-NEXT: 9 0 27 18 22 31 4 13 12 5 30 23 19 26 1 8
166
+ ; CHECK-NEXT: 3 10 17 24 28 21 14 7 6 15 20 29 25 16 11 2
167
+ ; CHECK-NEXT: 14 7 28 21 17 24 3 10 11 2 25 16 20 29 6 15
168
+ ; CHECK-NEXT: 4 13 22 31 27 18 9 0 1 8 19 26 30 23 12 5
169
+ ; CHECK-NEXT: 26 19 8 1 5 12 23 30 31 22 13 4 0 9 18 27
170
+ ; CHECK-NEXT: 16 25 2 11 15 6 29 20 21 28 7 14 10 3 24 17
151
171
;
152
172
entry:
153
173
br label %loop
@@ -676,27 +696,51 @@ exit: ; preds = %loop
676
696
ret i16 %crc.next
677
697
}
678
698
679
- define i16 @not.crc.excess.tc (i16 %msg , i16 %checksum ) {
699
+ define i16 @not.crc.excess.tc (i8 %msg , i16 %checksum ) {
680
700
; CHECK-LABEL: 'not.crc.excess.tc'
681
701
; CHECK-NEXT: Did not find a hash algorithm
682
- ; CHECK-NEXT: Reason: Loop iterations exceed bitwidth of result
702
+ ; CHECK-NEXT: Reason: Loop iterations exceed bitwidth of data
683
703
;
684
704
entry:
685
705
br label %loop
686
706
687
707
loop: ; preds = %loop, %entry
688
708
%iv = phi i8 [ 0 , %entry ], [ %iv.next , %loop ]
689
709
%crc = phi i16 [ %checksum , %entry ], [ %crc.next , %loop ]
690
- %data = phi i16 [ %msg , %entry ], [ %data.next , %loop ]
691
- %xor.crc.data = xor i16 %crc , %data
692
- %and.crc.data = and i16 %xor.crc.data , 1
693
- %data.next = lshr i16 %data , 1
694
- %check.sb = icmp eq i16 %and.crc.data , 0
710
+ %data = phi i8 [ %msg , %entry ], [ %data.next , %loop ]
711
+ %crc.trunc = trunc i16 %crc to i8
712
+ %xor.crc.data = xor i8 %crc.trunc , %data
713
+ %and.crc.data = and i8 %xor.crc.data , 1
714
+ %data.next = lshr i8 %data , 1
715
+ %check.sb = icmp eq i8 %and.crc.data , 0
695
716
%crc.lshr = lshr i16 %crc , 1
696
717
%crc.xor = xor i16 %crc.lshr , -24575
697
718
%crc.next = select i1 %check.sb , i16 %crc.lshr , i16 %crc.xor
698
719
%iv.next = add nuw nsw i8 %iv , 1
699
- %exit.cond = icmp samesign ult i8 %iv , 31
720
+ %exit.cond = icmp samesign ult i8 %iv , 15
721
+ br i1 %exit.cond , label %loop , label %exit
722
+
723
+ exit: ; preds = %loop
724
+ ret i16 %crc.next
725
+ }
726
+
727
+ define i16 @not.crc.init.arg.excess.tc (i16 %crc.init ) {
728
+ ; CHECK-LABEL: 'not.crc.init.arg.excess.tc'
729
+ ; CHECK-NEXT: Did not find a hash algorithm
730
+ ; CHECK-NEXT: Reason: Loop iterations exceed bitwidth of data
731
+ ;
732
+ entry:
733
+ br label %loop
734
+
735
+ loop: ; preds = %loop, %entry
736
+ %iv = phi i32 [ 0 , %entry ], [ %iv.next , %loop ]
737
+ %crc = phi i16 [ %crc.init , %entry ], [ %crc.next , %loop ]
738
+ %crc.shl = shl i16 %crc , 1
739
+ %crc.xor = xor i16 %crc.shl , 4129
740
+ %check.sb = icmp slt i16 %crc , 0
741
+ %crc.next = select i1 %check.sb , i16 %crc.xor , i16 %crc.shl
742
+ %iv.next = add nuw nsw i32 %iv , 1
743
+ %exit.cond = icmp samesign ult i32 %iv , 31
700
744
br i1 %exit.cond , label %loop , label %exit
701
745
702
746
exit: ; preds = %loop
0 commit comments