1; RUN: llc < %s -mcpu=atom -mtriple=i686-linux | FileCheck %s 2 3define i32 @Test_get_quotient(i32 %a, i32 %b) nounwind { 4; CHECK-LABEL: Test_get_quotient: 5; CHECK: orl %ecx, %edx 6; CHECK-NEXT: testl $-256, %edx 7; CHECK-NEXT: je 8; CHECK: idivl 9; CHECK: ret 10; CHECK: divb 11; CHECK: ret 12 %result = sdiv i32 %a, %b 13 ret i32 %result 14} 15 16define i32 @Test_get_remainder(i32 %a, i32 %b) nounwind { 17; CHECK-LABEL: Test_get_remainder: 18; CHECK: orl %ecx, %edx 19; CHECK-NEXT: testl $-256, %edx 20; CHECK-NEXT: je 21; CHECK: idivl 22; CHECK: ret 23; CHECK: divb 24; CHECK: ret 25 %result = srem i32 %a, %b 26 ret i32 %result 27} 28 29define i32 @Test_get_quotient_and_remainder(i32 %a, i32 %b) nounwind { 30; CHECK-LABEL: Test_get_quotient_and_remainder: 31; CHECK: orl %ecx, %edx 32; CHECK-NEXT: testl $-256, %edx 33; CHECK-NEXT: je 34; CHECK: idivl 35; CHECK: divb 36; CHECK: addl 37; CHECK: ret 38; CHECK-NOT: idivl 39; CHECK-NOT: divb 40 %resultdiv = sdiv i32 %a, %b 41 %resultrem = srem i32 %a, %b 42 %result = add i32 %resultdiv, %resultrem 43 ret i32 %result 44} 45 46define i32 @Test_use_div_and_idiv(i32 %a, i32 %b) nounwind { 47; CHECK-LABEL: Test_use_div_and_idiv: 48; CHECK: idivl 49; CHECK: divb 50; CHECK: divl 51; CHECK: divb 52; CHECK: addl 53; CHECK: ret 54 %resultidiv = sdiv i32 %a, %b 55 %resultdiv = udiv i32 %a, %b 56 %result = add i32 %resultidiv, %resultdiv 57 ret i32 %result 58} 59 60define i32 @Test_use_div_imm_imm() nounwind { 61; CHECK-LABEL: Test_use_div_imm_imm: 62; CHECK: movl $64 63 %resultdiv = sdiv i32 256, 4 64 ret i32 %resultdiv 65} 66 67define i32 @Test_use_div_reg_imm(i32 %a) nounwind { 68; CHECK-LABEL: Test_use_div_reg_imm: 69; CHECK-NOT: test 70; CHECK-NOT: idiv 71; CHECK-NOT: divb 72 %resultdiv = sdiv i32 %a, 33 73 ret i32 %resultdiv 74} 75 76define i32 @Test_use_rem_reg_imm(i32 %a) nounwind { 77; CHECK-LABEL: Test_use_rem_reg_imm: 78; CHECK-NOT: test 79; CHECK-NOT: idiv 80; CHECK-NOT: divb 81 %resultrem = srem i32 %a, 33 82 ret i32 %resultrem 83} 84 85define i32 @Test_use_divrem_reg_imm(i32 %a) nounwind { 86; CHECK-LABEL: Test_use_divrem_reg_imm: 87; CHECK-NOT: test 88; CHECK-NOT: idiv 89; CHECK-NOT: divb 90 %resultdiv = sdiv i32 %a, 33 91 %resultrem = srem i32 %a, 33 92 %result = add i32 %resultdiv, %resultrem 93 ret i32 %result 94} 95 96define i32 @Test_use_div_imm_reg(i32 %a) nounwind { 97; CHECK-LABEL: Test_use_div_imm_reg: 98; CHECK: test 99; CHECK: idiv 100; CHECK: divb 101 %resultdiv = sdiv i32 4, %a 102 ret i32 %resultdiv 103} 104 105define i32 @Test_use_rem_imm_reg(i32 %a) nounwind { 106; CHECK-LABEL: Test_use_rem_imm_reg: 107; CHECK: test 108; CHECK: idiv 109; CHECK: divb 110 %resultdiv = sdiv i32 4, %a 111 ret i32 %resultdiv 112} 113