1 ; RUN: llc -mattr=mul,movw < %s -march=avr | FileCheck %s
3 ; Unsigned 8-bit division
4 define i8 @udiv8(i8 %a, i8 %b) {
6 ; CHECK: call __udivmodqi4
9 %quotient = udiv i8 %a, %b
13 ; Signed 8-bit division
14 define i8 @sdiv8(i8 %a, i8 %b) {
16 ; CHECK: call __divmodqi4
19 %quotient = sdiv i8 %a, %b
23 ; Unsigned 16-bit division
24 define i16 @udiv16(i16 %a, i16 %b) {
25 ; CHECK-LABEL: udiv16:
26 ; CHECK: call __udivmodhi4
27 ; CHECK-NEXT: movw r24, r22
29 %quot = udiv i16 %a, %b
33 ; Signed 16-bit division
34 define i16 @sdiv16(i16 %a, i16 %b) {
35 ; CHECK-LABEL: sdiv16:
36 ; CHECK: call __divmodhi4
37 ; CHECK-NEXT: movw r24, r22
39 %quot = sdiv i16 %a, %b
43 ; Unsigned 32-bit division
44 define i32 @udiv32(i32 %a, i32 %b) {
45 ; CHECK-LABEL: udiv32:
46 ; CHECK: call __udivmodsi4
47 ; CHECK-NEXT: movw r22, r18
48 ; CHECK-NEXT: movw r24, r20
50 %quot = udiv i32 %a, %b
54 ; Signed 32-bit division
55 define i32 @sdiv32(i32 %a, i32 %b) {
56 ; CHECK-LABEL: sdiv32:
57 ; CHECK: call __divmodsi4
58 ; CHECK-NEXT: movw r22, r18
59 ; CHECK-NEXT: movw r24, r20
61 %quot = sdiv i32 %a, %b
65 ; Unsigned 64-bit division
66 define i64 @udiv64(i64 %a, i64 %b) {
67 ; CHECK-LABEL: udiv64:
68 ; CHECK: call __udivmoddi4
69 ; CHECK-NEXT: ldd r18, Y+1
70 ; CHECK-NEXT: ldd r19, Y+2
71 ; CHECK-NEXT: ldd r20, Y+3
72 ; CHECK-NEXT: ldd r21, Y+4
73 ; CHECK-NEXT: ldd r22, Y+5
74 ; CHECK-NEXT: ldd r23, Y+6
75 ; CHECK-NEXT: ldd r24, Y+7
76 ; CHECK-NEXT: ldd r25, Y+8
78 %quot = udiv i64 %a, %b
82 ; Signed 64-bit division
83 define i64 @sdiv64(i64 %a, i64 %b) {
84 ; CHECK-LABEL: sdiv64:
85 ; CHECK: call __divmoddi4
86 ; CHECK-NEXT: ldd r18, Y+1
87 ; CHECK-NEXT: ldd r19, Y+2
88 ; CHECK-NEXT: ldd r20, Y+3
89 ; CHECK-NEXT: ldd r21, Y+4
90 ; CHECK-NEXT: ldd r22, Y+5
91 ; CHECK-NEXT: ldd r23, Y+6
92 ; CHECK-NEXT: ldd r24, Y+7
93 ; CHECK-NEXT: ldd r25, Y+8
95 %quot = sdiv i64 %a, %b
99 ; Unsigned 128-bit division
100 define i128 @udiv128(i128 %a, i128 %b) {
101 ; CHECK-LABEL: udiv128:
102 ; CHECK: call __udivmodti4
104 %quot = udiv i128 %a, %b
108 ; Signed 128-bit division
109 define i128 @sdiv128(i128 %a, i128 %b) {
110 ; CHECK-LABEL: sdiv128:
111 ; CHECK: call __divmodti4
113 %quot = sdiv i128 %a, %b