• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -mattr=mul,movw < %s -march=avr | FileCheck %s
2
3; Unsigned 8-bit division
4define i8 @udiv8(i8 %a, i8 %b) {
5; CHECK-LABEL: div8:
6; CHECK: call __udivmodqi4
7; CHECK-NEXT: ret
8
9  %quotient = udiv i8 %a, %b
10  ret i8 %quotient
11}
12
13; Signed 8-bit division
14define i8 @sdiv8(i8 %a, i8 %b) {
15; CHECK-LABEL: sdiv8:
16; CHECK: call __divmodqi4
17; CHECK-NEXT: ret
18
19  %quotient = sdiv i8 %a, %b
20  ret i8 %quotient
21}
22
23; Unsigned 16-bit division
24define i16 @udiv16(i16 %a, i16 %b) {
25; CHECK-LABEL: udiv16:
26; CHECK: call __udivmodhi4
27; CHECK-NEXT: movw r24, r22
28; CHECK-NEXT: ret
29  %quot = udiv i16 %a, %b
30  ret i16 %quot
31}
32
33; Signed 16-bit division
34define i16 @sdiv16(i16 %a, i16 %b) {
35; CHECK-LABEL: sdiv16:
36; CHECK: call __divmodhi4
37; CHECK-NEXT: movw r24, r22
38; CHECK-NEXT: ret
39  %quot = sdiv i16 %a, %b
40  ret i16 %quot
41}
42
43; Unsigned 32-bit division
44define 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
49; CHECK-NEXT: ret
50  %quot = udiv i32 %a, %b
51  ret i32 %quot
52}
53
54; Signed 32-bit division
55define 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
60; CHECK-NEXT: ret
61  %quot = sdiv i32 %a, %b
62  ret i32 %quot
63}
64
65; Unsigned 64-bit division
66define i64 @udiv64(i64 %a, i64 %b) {
67; CHECK-LABEL: udiv64:
68; CHECK: call __udivdi3
69; CHECK: ret
70  %quot = udiv i64 %a, %b
71  ret i64 %quot
72}
73
74; Signed 64-bit division
75define i64 @sdiv64(i64 %a, i64 %b) {
76; CHECK-LABEL: sdiv64:
77; CHECK: call __divdi3
78; CHECK: ret
79  %quot = sdiv i64 %a, %b
80  ret i64 %quot
81}
82
83; Unsigned 128-bit division
84define i128 @udiv128(i128 %a, i128 %b) {
85; CHECK-LABEL: udiv128:
86; CHECK: call __udivti3
87; CHECK: ret
88  %quot = udiv i128 %a, %b
89  ret i128 %quot
90}
91
92; Signed 128-bit division
93define i128 @sdiv128(i128 %a, i128 %b) {
94; CHECK-LABEL: sdiv128:
95; CHECK: call __divti3
96; CHECK: ret
97  %quot = sdiv i128 %a, %b
98  ret i128 %quot
99}
100
101