1; RUN: llc < %s -march=avr | FileCheck %s 2 3; Optimize for speed. 4; CHECK-LABEL: shift_i8_i8_speed 5define i8 @shift_i8_i8_speed(i8 %a, i8 %b) { 6 ; CHECK: dec r22 7 ; CHECK-NEXT: brmi .LBB0_2 8 ; CHECK-NEXT: .LBB0_1: 9 ; CHECK-NEXT: lsl r24 10 ; CHECK-NEXT: dec r22 11 ; CHECK-NEXT: brpl .LBB0_1 12 ; CHECK-NEXT: .LBB0_2: 13 ; CHECK-NEXT: ret 14 %result = shl i8 %a, %b 15 ret i8 %result 16} 17 18; Optimize for size (producing slightly smaller code). 19; CHECK-LABEL: shift_i8_i8_size 20define i8 @shift_i8_i8_size(i8 %a, i8 %b) optsize { 21 ; CHECK: .LBB1_1: 22 ; CHECK-NEXT: dec r22 23 ; CHECK-NEXT: brmi .LBB1_3 24 ; CHECK: lsl r24 25 ; CHECK-NEXT: rjmp .LBB1_1 26 ; CHECK-NEXT: .LBB1_3: 27 ; CHECK-NEXT: ret 28 %result = shl i8 %a, %b 29 ret i8 %result 30} 31 32; CHECK-LABEL: shift_i16_i16 33define i16 @shift_i16_i16(i16 %a, i16 %b) { 34 ; CHECK: dec r22 35 ; CHECK-NEXT: brmi .LBB2_2 36 ; CHECK-NEXT: .LBB2_1: 37 ; CHECK-NEXT: lsl r24 38 ; CHECK-NEXT: rol r25 39 ; CHECK-NEXT: dec r22 40 ; CHECK-NEXT: brpl .LBB2_1 41 ; CHECK-NEXT: .LBB2_2: 42 ; CHECK-NEXT: ret 43 %result = shl i16 %a, %b 44 ret i16 %result 45} 46 47; CHECK-LABEL: shift_i64_i64 48define i64 @shift_i64_i64(i64 %a, i64 %b) { 49 ; CHECK: call __ashldi3 50 %result = shl i64 %a, %b 51 ret i64 %result 52} 53