blob: 1ebf9c667e72beea34710325bf0a6356e1a36937 [file] [log] [blame]
Petar Jovanovice578e972016-04-11 15:24:23 +00001; RUN: llc < %s -march=mips -mcpu=mips2 -relocation-model=pic | FileCheck %s \
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +00002; RUN: -check-prefix=GP32 -check-prefix=NOT-R6 -check-prefix=NOT-R2-R6
Petar Jovanovice578e972016-04-11 15:24:23 +00003; RUN: llc < %s -march=mips -mcpu=mips32 -relocation-model=pic | FileCheck %s \
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +00004; RUN: -check-prefix=GP32 -check-prefix=NOT-R6 -check-prefix=NOT-R2-R6
Petar Jovanovice578e972016-04-11 15:24:23 +00005; RUN: llc < %s -march=mips -mcpu=mips32r2 -relocation-model=pic | FileCheck %s -check-prefix=GP32 \
Daniel Sanders17793142015-02-18 16:24:50 +00006; RUN: -check-prefix=R2-R5 -check-prefix=R2-R6 -check-prefix=NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +00007; RUN: llc < %s -march=mips -mcpu=mips32r3 -relocation-model=pic | FileCheck %s -check-prefix=GP32 \
Daniel Sanders17793142015-02-18 16:24:50 +00008; RUN: -check-prefix=R2-R5 -check-prefix=R2-R6 -check-prefix=NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +00009; RUN: llc < %s -march=mips -mcpu=mips32r5 -relocation-model=pic | FileCheck %s -check-prefix=GP32 \
Daniel Sanders17793142015-02-18 16:24:50 +000010; RUN: -check-prefix=R2-R5 -check-prefix=R2-R6 -check-prefix=NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000011; RUN: llc < %s -march=mips -mcpu=mips32r6 -relocation-model=pic | FileCheck %s \
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000012; RUN: -check-prefix=GP32 -check-prefix=R6 -check-prefix=R2-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000013; RUN: llc < %s -march=mips64 -mcpu=mips3 -relocation-model=pic | FileCheck %s \
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000014; RUN: -check-prefix=GP64-NOT-R6 -check-prefix=NOT-R6 -check-prefix=NOT-R2-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000015; RUN: llc < %s -march=mips64 -mcpu=mips4 -relocation-model=pic | FileCheck %s \
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000016; RUN: -check-prefix=GP64-NOT-R6 -check-prefix=NOT-R6 -check-prefix=NOT-R2-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000017; RUN: llc < %s -march=mips64 -mcpu=mips64 -relocation-model=pic | FileCheck %s \
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000018; RUN: -check-prefix=GP64-NOT-R6 -check-prefix=NOT-R6 -check-prefix=NOT-R2-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000019; RUN: llc < %s -march=mips64 -mcpu=mips64r2 -relocation-model=pic | FileCheck %s \
Daniel Sanders17793142015-02-18 16:24:50 +000020; RUN: -check-prefix=R2-R5 -check-prefix=R2-R6 \
21; RUN: -check-prefix=GP64-NOT-R6 -check-prefix=NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000022; RUN: llc < %s -march=mips64 -mcpu=mips64r3 -relocation-model=pic | FileCheck %s \
Daniel Sanders17793142015-02-18 16:24:50 +000023; RUN: -check-prefix=R2-R5 -check-prefix=R2-R6 \
24; RUN: -check-prefix=GP64-NOT-R6 -check-prefix=NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000025; RUN: llc < %s -march=mips64 -mcpu=mips64r5 -relocation-model=pic | FileCheck %s \
Daniel Sanders17793142015-02-18 16:24:50 +000026; RUN: -check-prefix=R2-R5 -check-prefix=R2-R6 \
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000027; RUN: -check-prefix=GP64-NOT-R6 -check-prefix=NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000028; RUN: llc < %s -march=mips64 -mcpu=mips64r6 -relocation-model=pic | FileCheck %s \
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000029; RUN: -check-prefix=64R6 -check-prefix=R6 -check-prefix=R2-R6
30
31define signext i1 @srem_i1(i1 signext %a, i1 signext %b) {
32entry:
33; ALL-LABEL: srem_i1:
34
35 ; NOT-R6: div $zero, $4, $5
36 ; NOT-R6: teq $5, $zero, 7
37 ; NOT-R6: mfhi $[[T0:[0-9]+]]
38 ; NOT-R6: sll $[[T1:[0-9]+]], $[[T0]], 31
39 ; NOT-R6: sra $2, $[[T1]], 31
40
41 ; R6: mod $[[T0:[0-9]+]], $4, $5
42 ; R6: teq $5, $zero, 7
43 ; R6: sll $[[T3:[0-9]+]], $[[T0]], 31
44 ; R6: sra $2, $[[T3]], 31
45
46 %r = srem i1 %a, %b
47 ret i1 %r
48}
49
50define signext i8 @srem_i8(i8 signext %a, i8 signext %b) {
51entry:
52; ALL-LABEL: srem_i8:
53
54 ; NOT-R2-R6: div $zero, $4, $5
55 ; NOT-R2-R6: teq $5, $zero, 7
56 ; NOT-R2-R6: mfhi $[[T0:[0-9]+]]
57 ; NOT-R2-R6: sll $[[T1:[0-9]+]], $[[T0]], 24
58 ; NOT-R2-R6: sra $2, $[[T1]], 24
59
Daniel Sanders17793142015-02-18 16:24:50 +000060 ; R2-R5: div $zero, $4, $5
61 ; R2-R5: teq $5, $zero, 7
62 ; R2-R5: mfhi $[[T0:[0-9]+]]
63 ; R2-R5: seb $2, $[[T0]]
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000064
65 ; R6: mod $[[T0:[0-9]+]], $4, $5
66 ; R6: teq $5, $zero, 7
67 ; R6: seb $2, $[[T0]]
68
69 %r = srem i8 %a, %b
70 ret i8 %r
71}
72
73define signext i16 @srem_i16(i16 signext %a, i16 signext %b) {
74entry:
75; ALL-LABEL: srem_i16:
76
77 ; NOT-R2-R6: div $zero, $4, $5
78 ; NOT-R2-R6: teq $5, $zero, 7
79 ; NOT-R2-R6: mfhi $[[T0:[0-9]+]]
80 ; NOT-R2-R6: sll $[[T1:[0-9]+]], $[[T0]], 16
81 ; NOT-R2-R6: sra $2, $[[T1]], 16
82
Daniel Sanders17793142015-02-18 16:24:50 +000083 ; R2-R5: div $zero, $4, $5
84 ; R2-R5: teq $5, $zero, 7
85 ; R2-R5: mfhi $[[T0:[0-9]+]]
Zoran Jovanovic2b7cc5a2016-04-02 23:06:13 +000086 ; R2-R5: seh $2, $[[T1]]
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000087
88 ; R6: mod $[[T0:[0-9]+]], $4, $5
89 ; R6: teq $5, $zero, 7
90 ; R6: seh $2, $[[T0]]
91
92 %r = srem i16 %a, %b
93 ret i16 %r
94}
95
96define signext i32 @srem_i32(i32 signext %a, i32 signext %b) {
97entry:
98; ALL-LABEL: srem_i32:
99
100 ; NOT-R6: div $zero, $4, $5
101 ; NOT-R6: teq $5, $zero, 7
102 ; NOT-R6: mfhi $2
103
104 ; R6: mod $2, $4, $5
105 ; R6: teq $5, $zero, 7
106
107 %r = srem i32 %a, %b
108 ret i32 %r
109}
110
111define signext i64 @srem_i64(i64 signext %a, i64 signext %b) {
112entry:
113; ALL-LABEL: srem_i64:
114
115 ; GP32: lw $25, %call16(__moddi3)($gp)
116
117 ; GP64-NOT-R6: ddiv $zero, $4, $5
118 ; GP64-NOT-R6: teq $5, $zero, 7
119 ; GP64-NOT-R6: mfhi $2
120
121 ; 64R6: dmod $2, $4, $5
122 ; 64R6: teq $5, $zero, 7
123
124 %r = srem i64 %a, %b
125 ret i64 %r
126}
Vasileios Kalintirisef96a8e2015-01-26 12:33:22 +0000127
128define signext i128 @srem_i128(i128 signext %a, i128 signext %b) {
129entry:
130; ALL-LABEL: srem_i128:
131
132 ; GP32: lw $25, %call16(__modti3)($gp)
133
134 ; GP64-NOT-R6: ld $25, %call16(__modti3)($gp)
135 ; 64-R6: ld $25, %call16(__modti3)($gp)
136
137 %r = srem i128 %a, %b
138 ret i128 %r
139}