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 __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 77; CHECK: ret 78 %quot = udiv i64 %a, %b 79 ret i64 %quot 80} 81 82; Signed 64-bit division 83define 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 94; CHECK: ret 95 %quot = sdiv i64 %a, %b 96 ret i64 %quot 97} 98 99; Unsigned 128-bit division 100define i128 @udiv128(i128 %a, i128 %b) { 101; CHECK-LABEL: udiv128: 102; CHECK: call __udivmodti4 103; CHECK: ret 104 %quot = udiv i128 %a, %b 105 ret i128 %quot 106} 107 108; Signed 128-bit division 109define i128 @sdiv128(i128 %a, i128 %b) { 110; CHECK-LABEL: sdiv128: 111; CHECK: call __divmodti4 112; CHECK: ret 113 %quot = sdiv i128 %a, %b 114 ret i128 %quot 115} 116 117