brintos

brintos / llvm-project-archived public Read only

0
0
Text · 9.1 KiB · 2873849 Raw
292 lines · plain
1; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output -mtriple=systemz-unknown -mcpu=z13 \2; RUN:  | FileCheck %s -check-prefix=COST3 4; Check that all divide/remainder instructions are implemented by cheaper instructions.5; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 -o - | FileCheck %s6; CHECK-NOT: dsg7; CHECK-NOT: dl8 9; Check costs of divisions/remainders by a vector of constants that is *not*10; a power of two. A sequence containing a multiply and shifts will replace11; the divide instruction.12 13; Scalar sdiv14 15define i64 @fun0(i64 %a) {16  %r = sdiv i64 %a, 2017  ret i64 %r18; COST: Cost Model: Found an estimated cost of 10 for instruction:   %r = sdiv i64 %a, 2019}20 21define i32 @fun1(i32 %a) {22  %r = sdiv i32 %a, 2023  ret i32 %r24; COST: Cost Model: Found an estimated cost of 10 for instruction:   %r = sdiv i32 %a, 2025}26 27define i16 @fun2(i16 %a) {28  %r = sdiv i16 %a, 2029  ret i16 %r30; COST: Cost Model: Found an estimated cost of 10 for instruction:   %r = sdiv i16 %a, 2031}32 33define i8 @fun3(i8 %a) {34  %r = sdiv i8 %a, 2035  ret i8 %r36; COST: Cost Model: Found an estimated cost of 10 for instruction:   %r = sdiv i8 %a, 2037}38 39; Vector sdiv40 41define <2 x i64> @fun4(<2 x i64> %a) {42  %r = sdiv <2 x i64> %a, <i64 20, i64 21>43  ret <2 x i64> %r44; COST: Cost Model: Found an estimated cost of 24 for instruction:   %r = sdiv <2 x i64>45}46 47define <4 x i32> @fun5(<4 x i32> %a) {48  %r = sdiv <4 x i32> %a, <i32 20, i32 20, i32 20, i32 20>49  ret <4 x i32> %r50; COST: Cost Model: Found an estimated cost of 49 for instruction:   %r = sdiv <4 x i32>51}52 53define <2 x i32> @fun6(<2 x i32> %a) {54  %r = sdiv <2 x i32> %a, <i32 20, i32 21>55  ret <2 x i32> %r56; COST: Cost Model: Found an estimated cost of 25 for instruction:   %r = sdiv <2 x i32>57}58 59define <8 x i16> @fun7(<8 x i16> %a) {60  %r = sdiv <8 x i16> %a, <i16 20, i16 20, i16 20, i16 20, i16 20, i16 20, i16 20, i16 20>61  ret <8 x i16> %r62; COST: Cost Model: Found an estimated cost of 97 for instruction:   %r = sdiv <8 x i16>63}64 65define <4 x i16> @fun8(<4 x i16> %a) {66  %r = sdiv <4 x i16> %a, <i16 20, i16 20, i16 20, i16 21>67  ret <4 x i16> %r68; COST: Cost Model: Found an estimated cost of 49 for instruction:   %r = sdiv <4 x i16>69}70 71define <16 x i8> @fun9(<16 x i8> %a) {72  %r = sdiv <16 x i8> %a, <i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20>73  ret <16 x i8> %r74; COST: Cost Model: Found an estimated cost of 193 for instruction:   %r = sdiv <16 x i8>75}76 77define <8 x i8> @fun10(<8 x i8> %a) {78  %r = sdiv <8 x i8> %a, <i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 21>79  ret <8 x i8> %r80; COST: Cost Model: Found an estimated cost of 97 for instruction:   %r = sdiv <8 x i8>81}82 83; Scalar udiv84 85define i64 @fun11(i64 %a) {86  %r = udiv i64 %a, 2087  ret i64 %r88; COST: Cost Model: Found an estimated cost of 10 for instruction:   %r = udiv i64 %a, 2089}90 91define i32 @fun12(i32 %a) {92  %r = udiv i32 %a, 2093  ret i32 %r94; COST: Cost Model: Found an estimated cost of 10 for instruction:   %r = udiv i32 %a, 2095}96 97define i16 @fun13(i16 %a) {98  %r = udiv i16 %a, 2099  ret i16 %r100; COST: Cost Model: Found an estimated cost of 10 for instruction:   %r = udiv i16 %a, 20101}102 103define i8 @fun14(i8 %a) {104  %r = udiv i8 %a, 20105  ret i8 %r106; COST: Cost Model: Found an estimated cost of 10 for instruction:   %r = udiv i8107}108 109; Vector udiv110 111define <2 x i64> @fun15(<2 x i64> %a) {112  %r = udiv <2 x i64> %a, <i64 20, i64 20>113  ret <2 x i64> %r114; COST: Cost Model: Found an estimated cost of 24 for instruction:   %r = udiv <2 x i64>115}116 117define <4 x i32> @fun16(<4 x i32> %a) {118  %r = udiv <4 x i32> %a, <i32 20, i32 20, i32 20, i32 21>119  ret <4 x i32> %r120; COST: Cost Model: Found an estimated cost of 49 for instruction:   %r = udiv <4 x i32>121}122 123define <2 x i32> @fun17(<2 x i32> %a) {124  %r = udiv <2 x i32> %a, <i32 20, i32 20>125  ret <2 x i32> %r126; COST: Cost Model: Found an estimated cost of 25 for instruction:   %r = udiv <2 x i32>127}128 129define <8 x i16> @fun18(<8 x i16> %a) {130  %r = udiv <8 x i16> %a, <i16 20, i16 20, i16 20, i16 20, i16 20, i16 20, i16 20, i16 21>131  ret <8 x i16> %r132; COST: Cost Model: Found an estimated cost of 97 for instruction:   %r = udiv <8 x i16>133}134 135define <4 x i16> @fun19(<4 x i16> %a) {136  %r = udiv <4 x i16> %a, <i16 20, i16 20, i16 20, i16 20>137  ret <4 x i16> %r138; COST: Cost Model: Found an estimated cost of 49 for instruction:   %r = udiv <4 x i16>139}140 141define <16 x i8> @fun20(<16 x i8> %a) {142  %r = udiv <16 x i8> %a, <i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 21>143  ret <16 x i8> %r144; COST: Cost Model: Found an estimated cost of 193 for instruction:   %r = udiv <16 x i8>145}146 147define <8 x i8> @fun21(<8 x i8> %a) {148  %r = udiv <8 x i8> %a, <i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20>149  ret <8 x i8> %r150; COST: Cost Model: Found an estimated cost of 97 for instruction:   %r = udiv <8 x i8>151}152 153; Scalar srem154 155define i64 @fun22(i64 %a) {156  %r = srem i64 %a, 20157  ret i64 %r158; COST: Cost Model: Found an estimated cost of 10 for instruction:   %r = srem i64159}160 161define i32 @fun23(i32 %a) {162  %r = srem i32 %a, 20163  ret i32 %r164; COST: Cost Model: Found an estimated cost of 10 for instruction:   %r = srem i32165}166 167define i16 @fun24(i16 %a) {168  %r = srem i16 %a, 20169  ret i16 %r170; COST: Cost Model: Found an estimated cost of 10 for instruction:   %r = srem i16171}172 173define i8 @fun25(i8 %a) {174  %r = srem i8 %a, 20175  ret i8 %r176; COST: Cost Model: Found an estimated cost of 10 for instruction:   %r = srem i8177}178 179; Vector srem180 181define <2 x i64> @fun26(<2 x i64> %a) {182  %r = srem <2 x i64> %a, <i64 20, i64 21>183  ret <2 x i64> %r184; COST: Cost Model: Found an estimated cost of 24 for instruction:   %r = srem <2 x i64>185}186 187define <4 x i32> @fun27(<4 x i32> %a) {188  %r = srem <4 x i32> %a, <i32 20, i32 20, i32 20, i32 20>189  ret <4 x i32> %r190; COST: Cost Model: Found an estimated cost of 49 for instruction:   %r = srem <4 x i32>191}192 193define <2 x i32> @fun28(<2 x i32> %a) {194  %r = srem <2 x i32> %a, <i32 20, i32 21>195  ret <2 x i32> %r196; COST: Cost Model: Found an estimated cost of 25 for instruction:   %r = srem <2 x i32>197}198 199define <8 x i16> @fun29(<8 x i16> %a) {200  %r = srem <8 x i16> %a, <i16 20, i16 20, i16 20, i16 20, i16 20, i16 20, i16 20, i16 20>201  ret <8 x i16> %r202; COST: Cost Model: Found an estimated cost of 97 for instruction:   %r = srem <8 x i16>203}204 205define <4 x i16> @fun30(<4 x i16> %a) {206  %r = srem <4 x i16> %a, <i16 20, i16 20, i16 20, i16 21>207  ret <4 x i16> %r208; COST: Cost Model: Found an estimated cost of 49 for instruction:   %r = srem <4 x i16>209}210 211define <16 x i8> @fun31(<16 x i8> %a) {212  %r = srem <16 x i8> %a, <i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20>213  ret <16 x i8> %r214; COST: Cost Model: Found an estimated cost of 193 for instruction:   %r = srem <16 x i8>215}216 217define <8 x i8> @fun32(<8 x i8> %a) {218  %r = srem <8 x i8> %a, <i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 21>219  ret <8 x i8> %r220; COST: Cost Model: Found an estimated cost of 97 for instruction:   %r = srem <8 x i8>221}222 223; Scalar urem224 225define i64 @fun33(i64 %a) {226  %r = urem i64 %a, 20227  ret i64 %r228; COST: Cost Model: Found an estimated cost of 10 for instruction:   %r = urem i64229}230 231define i32 @fun34(i32 %a) {232  %r = urem i32 %a, 20233  ret i32 %r234; COST: Cost Model: Found an estimated cost of 10 for instruction:   %r = urem i32235}236 237define i16 @fun35(i16 %a) {238  %r = urem i16 %a, 20239  ret i16 %r240; COST: Cost Model: Found an estimated cost of 10 for instruction:   %r = urem i16241}242 243define i8 @fun36(i8 %a) {244  %r = urem i8 %a, 20245  ret i8 %r246; COST: Cost Model: Found an estimated cost of 10 for instruction:   %r = urem i8247}248 249; Vector urem250 251define <2 x i64> @fun37(<2 x i64> %a) {252  %r = urem <2 x i64> %a, <i64 20, i64 20>253  ret <2 x i64> %r254; COST: Cost Model: Found an estimated cost of 24 for instruction:   %r = urem <2 x i64>255}256 257define <4 x i32> @fun38(<4 x i32> %a) {258  %r = urem <4 x i32> %a, <i32 20, i32 20, i32 20, i32 21>259  ret <4 x i32> %r260; COST: Cost Model: Found an estimated cost of 49 for instruction:   %r = urem <4 x i32>261}262 263define <2 x i32> @fun39(<2 x i32> %a) {264  %r = urem <2 x i32> %a, <i32 20, i32 20>265  ret <2 x i32> %r266; COST: Cost Model: Found an estimated cost of 25 for instruction:   %r = urem <2 x i32>267}268 269define <8 x i16> @fun40(<8 x i16> %a) {270  %r = urem <8 x i16> %a, <i16 20, i16 20, i16 20, i16 20, i16 20, i16 20, i16 20, i16 21>271  ret <8 x i16> %r272; COST: Cost Model: Found an estimated cost of 97 for instruction:   %r = urem <8 x i16>273}274 275define <4 x i16> @fun41(<4 x i16> %a) {276  %r = urem <4 x i16> %a, <i16 20, i16 20, i16 20, i16 20>277  ret <4 x i16> %r278; COST: Cost Model: Found an estimated cost of 49 for instruction:   %r = urem <4 x i16>279}280 281define <16 x i8> @fun42(<16 x i8> %a) {282  %r = urem <16 x i8> %a, <i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 21>283  ret <16 x i8> %r284; COST: Cost Model: Found an estimated cost of 193 for instruction:   %r = urem <16 x i8>285}286 287define <8 x i8> @fun43(<8 x i8> %a) {288  %r = urem <8 x i8> %a, <i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20>289  ret <8 x i8> %r290; COST: Cost Model: Found an estimated cost of 97 for instruction:   %r = urem <8 x i8>291}292