blob: 43ed0739b8dfe60a38a73b8fdac2fc648fdb6f95 [file] [log] [blame]
Matt Walaafeaee42014-08-07 13:47:30 -07001; This checks the correctness of the lowering code for the small
2; integer variants of sdiv and srem.
3
Jim Stichnoth729dbd02015-02-25 14:48:43 -08004; RUN: %p2i -i %s --filetype=obj --disassemble --args -O2 | FileCheck %s
5; RUN: %p2i -i %s --filetype=obj --disassemble --args -Om1 | FileCheck %s
Matt Walaafeaee42014-08-07 13:47:30 -07006
7define i32 @sdiv_i8(i32 %a.i32, i32 %b.i32) {
8entry:
9 %a = trunc i32 %a.i32 to i8
10 %b = trunc i32 %b.i32 to i8
11 %res = sdiv i8 %a, %b
12 %res.i32 = zext i8 %res to i32
13 ret i32 %res.i32
Jan Vounga2703ae2015-02-19 11:27:44 -080014; CHECK-LABEL: sdiv_i8
Matt Walaafeaee42014-08-07 13:47:30 -070015; CHECK: cbw
16; CHECK: idiv
17}
18
19define i32 @sdiv_i16(i32 %a.i32, i32 %b.i32) {
20entry:
21 %a = trunc i32 %a.i32 to i16
22 %b = trunc i32 %b.i32 to i16
23 %res = sdiv i16 %a, %b
24 %res.i32 = zext i16 %res to i32
25 ret i32 %res.i32
Jan Vounga2703ae2015-02-19 11:27:44 -080026; CHECK-LABEL: sdiv_i16
Matt Walaafeaee42014-08-07 13:47:30 -070027; CHECK: cwd
28; CHECK: idiv
29}
30
31define i32 @sdiv_i32(i32 %a, i32 %b) {
32entry:
33 %res = sdiv i32 %a, %b
34 ret i32 %res
Jan Vounga2703ae2015-02-19 11:27:44 -080035; CHECK-LABEL: sdiv_i32
Matt Walaafeaee42014-08-07 13:47:30 -070036; CHECK: cdq
37; CHECK: idiv
38}
39
40define i32 @srem_i8(i32 %a.i32, i32 %b.i32) {
41entry:
42 %a = trunc i32 %a.i32 to i8
43 %b = trunc i32 %b.i32 to i8
44 %res = srem i8 %a, %b
45 %res.i32 = zext i8 %res to i32
46 ret i32 %res.i32
Jan Vounga2703ae2015-02-19 11:27:44 -080047; CHECK-LABEL: srem_i8
Matt Walaafeaee42014-08-07 13:47:30 -070048; CHECK: cbw
49; CHECK: idiv
50}
51
52define i32 @srem_i16(i32 %a.i32, i32 %b.i32) {
53entry:
54 %a = trunc i32 %a.i32 to i16
55 %b = trunc i32 %b.i32 to i16
56 %res = srem i16 %a, %b
57 %res.i32 = zext i16 %res to i32
58 ret i32 %res.i32
Jan Vounga2703ae2015-02-19 11:27:44 -080059; CHECK-LABEL: srem_i16
Matt Walaafeaee42014-08-07 13:47:30 -070060; CHECK: cwd
61; CHECK: idiv
62}
63
64define i32 @srem_i32(i32 %a, i32 %b) {
65entry:
66 %res = srem i32 %a, %b
67 ret i32 %res
Jan Vounga2703ae2015-02-19 11:27:44 -080068; CHECK-LABEL: srem_i32
Matt Walaafeaee42014-08-07 13:47:30 -070069; CHECK: cdq
70; CHECK: idiv
71}