1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc -mtriple=i686-- < %s | FileCheck %s 3 4; No attributes, should not use idiv 5define i32 @test1(i32 inreg %x) { 6; CHECK-LABEL: test1: 7; CHECK: # %bb.0: # %entry 8; CHECK-NEXT: movl %eax, %ecx 9; CHECK-NEXT: sarl $31, %ecx 10; CHECK-NEXT: shrl $28, %ecx 11; CHECK-NEXT: addl %ecx, %eax 12; CHECK-NEXT: sarl $4, %eax 13; CHECK-NEXT: retl 14entry: 15 %div = sdiv i32 %x, 16 16 ret i32 %div 17} 18 19; Has minsize (-Oz) attribute, should generate idiv 20define i32 @test2(i32 inreg %x) minsize { 21; CHECK-LABEL: test2: 22; CHECK: # %bb.0: # %entry 23; CHECK-NEXT: pushl $16 24; CHECK-NEXT: .cfi_adjust_cfa_offset 4 25; CHECK-NEXT: popl %ecx 26; CHECK-NEXT: .cfi_adjust_cfa_offset -4 27; CHECK-NEXT: cltd 28; CHECK-NEXT: idivl %ecx 29; CHECK-NEXT: retl 30entry: 31 %div = sdiv i32 %x, 16 32 ret i32 %div 33} 34 35; Has optsize (-Os) attribute, should not generate idiv 36define i32 @test3(i32 inreg %x) optsize { 37; CHECK-LABEL: test3: 38; CHECK: # %bb.0: # %entry 39; CHECK-NEXT: movl %eax, %ecx 40; CHECK-NEXT: sarl $31, %ecx 41; CHECK-NEXT: shrl $28, %ecx 42; CHECK-NEXT: addl %ecx, %eax 43; CHECK-NEXT: sarl $4, %eax 44; CHECK-NEXT: retl 45entry: 46 %div = sdiv i32 %x, 16 47 ret i32 %div 48} 49 50 51