• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s -march=avr | FileCheck %s
2
3; Bit rotation tests.
4
5; CHECK-LABEL: rol8:
6define i8 @rol8(i8 %val, i8 %amt) {
7  ; CHECK:      andi r22, 7
8
9  ; CHECK-NEXT: dec r22
10  ; CHECK-NEXT: brmi .LBB0_2
11
12; CHECK-NEXT: .LBB0_1:
13  ; CHECK-NEXT: lsl r24
14  ; CHECK-NEXT: adc r24, r1
15  ; CHECK-NEXT: dec r22
16  ; CHECK-NEXT: brpl .LBB0_1
17
18; CHECK-NEXT: .LBB0_2:
19  ; CHECK-NEXT: ret
20  %mod = urem i8 %amt, 8
21
22  %inv = sub i8 8, %mod
23  %parta = shl i8 %val, %mod
24  %partb = lshr i8 %val, %inv
25
26  %rotl = or i8 %parta, %partb
27
28  ret i8 %rotl
29}
30
31
32; CHECK-LABEL: ror8:
33define i8 @ror8(i8 %val, i8 %amt) {
34  ; CHECK:      andi r22, 7
35
36  ; CHECK-NEXT: dec r22
37  ; CHECK-NEXT: brmi .LBB1_2
38
39; CHECK-NEXT: .LBB1_1:
40  ; CHECK-NEXT: lsr r24
41  ; CHECK-NEXT: ldi r0, 0
42  ; CHECK-NEXT: ror r0
43  ; CHECK-NEXT: or r24, r0
44  ; CHECK-NEXT: dec r22
45  ; CHECK-NEXT: brpl .LBB1_1
46
47; CHECK-NEXT: .LBB1_2:
48  ; CHECK-NEXT: ret
49  %mod = urem i8 %amt, 8
50
51  %inv = sub i8 8, %mod
52  %parta = lshr i8 %val, %mod
53  %partb = shl i8 %val, %inv
54
55  %rotr = or i8 %parta, %partb
56
57  ret i8 %rotr
58}
59
60