492 lines · plain
1; Test the use of TEST UNDER MASK for 32-bit operations.2;3; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z196 | FileCheck %s4 5@g = global i32 06 7; Check the lowest useful TMLL value.8define void @f1(i32 %a) {9; CHECK-LABEL: f1:10; CHECK: tmll %r2, 111; CHECK: ber %r1412; CHECK: br %r1413entry:14 %and = and i32 %a, 115 %cmp = icmp eq i32 %and, 016 br i1 %cmp, label %exit, label %store17 18store:19 store i32 1, ptr@g20 br label %exit21 22exit:23 ret void24}25 26; Check the high end of the TMLL range.27define void @f2(i32 %a) {28; CHECK-LABEL: f2:29; CHECK: tmll %r2, 6553530; CHECK: bner %r1431; CHECK: br %r1432entry:33 %and = and i32 %a, 6553534 %cmp = icmp ne i32 %and, 035 br i1 %cmp, label %exit, label %store36 37store:38 store i32 1, ptr@g39 br label %exit40 41exit:42 ret void43}44 45; Check the lowest useful TMLH value, which is the next value up.46define void @f3(i32 %a) {47; CHECK-LABEL: f3:48; CHECK: tmlh %r2, 149; CHECK: bner %r1450; CHECK: br %r1451entry:52 %and = and i32 %a, 6553653 %cmp = icmp ne i32 %and, 054 br i1 %cmp, label %exit, label %store55 56store:57 store i32 1, ptr@g58 br label %exit59 60exit:61 ret void62}63 64; Check the next value up again, which cannot use TM.65define void @f4(i32 %a) {66; CHECK-LABEL: f4:67; CHECK-NOT: {{tm[lh].}}68; CHECK: br %r1469entry:70 %and = and i32 %a, 429490175971 %cmp = icmp eq i32 %and, 072 br i1 %cmp, label %exit, label %store73 74store:75 store i32 1, ptr@g76 br label %exit77 78exit:79 ret void80}81 82; Check the high end of the TMLH range.83define void @f5(i32 %a) {84; CHECK-LABEL: f5:85; CHECK: tmlh %r2, 6553586; CHECK: ber %r1487; CHECK: br %r1488entry:89 %and = and i32 %a, 429490176090 %cmp = icmp eq i32 %and, 091 br i1 %cmp, label %exit, label %store92 93store:94 store i32 1, ptr@g95 br label %exit96 97exit:98 ret void99}100 101; Check that we can use TMLL for LT comparisons that are equivalent to102; an equality comparison with zero.103define void @f6(i32 %a) {104; CHECK-LABEL: f6:105; CHECK: tmll %r2, 240106; CHECK: ber %r14107; CHECK: br %r14108entry:109 %and = and i32 %a, 240110 %cmp = icmp slt i32 %and, 16111 br i1 %cmp, label %exit, label %store112 113store:114 store i32 1, ptr@g115 br label %exit116 117exit:118 ret void119}120 121; ...same again with LE.122define void @f7(i32 %a) {123; CHECK-LABEL: f7:124; CHECK: tmll %r2, 240125; CHECK: ber %r14126; CHECK: br %r14127entry:128 %and = and i32 %a, 240129 %cmp = icmp sle i32 %and, 15130 br i1 %cmp, label %exit, label %store131 132store:133 store i32 1, ptr@g134 br label %exit135 136exit:137 ret void138}139 140; Check that we can use TMLL for GE comparisons that are equivalent to141; an inequality comparison with zero.142define void @f8(i32 %a) {143; CHECK-LABEL: f8:144; CHECK: tmll %r2, 240145; CHECK: bner %r14146; CHECK: br %r14147entry:148 %and = and i32 %a, 240149 %cmp = icmp uge i32 %and, 16150 br i1 %cmp, label %exit, label %store151 152store:153 store i32 1, ptr@g154 br label %exit155 156exit:157 ret void158}159 160; ...same again with GT.161define void @f9(i32 %a) {162; CHECK-LABEL: f9:163; CHECK: tmll %r2, 240164; CHECK: bner %r14165; CHECK: br %r14166entry:167 %and = and i32 %a, 240168 %cmp = icmp ugt i32 %and, 15169 br i1 %cmp, label %exit, label %store170 171store:172 store i32 1, ptr@g173 br label %exit174 175exit:176 ret void177}178 179; Check that we can use TMLL for LT comparisons that effectively180; test whether the top bit is clear.181define void @f10(i32 %a) {182; CHECK-LABEL: f10:183; CHECK: tmll %r2, 35184; CHECK: bler %r14185; CHECK: br %r14186entry:187 %and = and i32 %a, 35188 %cmp = icmp ult i32 %and, 8189 br i1 %cmp, label %exit, label %store190 191store:192 store i32 1, ptr@g193 br label %exit194 195exit:196 ret void197}198 199; ...same again with LE.200define void @f11(i32 %a) {201; CHECK-LABEL: f11:202; CHECK: tmll %r2, 35203; CHECK: bler %r14204; CHECK: br %r14205entry:206 %and = and i32 %a, 35207 %cmp = icmp ule i32 %and, 31208 br i1 %cmp, label %exit, label %store209 210store:211 store i32 1, ptr@g212 br label %exit213 214exit:215 ret void216}217 218; Check that we can use TMLL for GE comparisons that effectively test219; whether the top bit is set.220define void @f12(i32 %a) {221; CHECK-LABEL: f12:222; CHECK: tmll %r2, 140223; CHECK: bnler %r14224; CHECK: br %r14225entry:226 %and = and i32 %a, 140227 %cmp = icmp uge i32 %and, 128228 br i1 %cmp, label %exit, label %store229 230store:231 store i32 1, ptr@g232 br label %exit233 234exit:235 ret void236}237 238; ...same again for GT.239define void @f13(i32 %a) {240; CHECK-LABEL: f13:241; CHECK: tmll %r2, 140242; CHECK: bnler %r14243; CHECK: br %r14244entry:245 %and = and i32 %a, 140246 %cmp = icmp ugt i32 %and, 126247 br i1 %cmp, label %exit, label %store248 249store:250 store i32 1, ptr@g251 br label %exit252 253exit:254 ret void255}256 257; Check that we can use TMLL for equality comparisons with the mask.258define void @f14(i32 %a) {259; CHECK-LABEL: f14:260; CHECK: tmll %r2, 101261; CHECK: bor %r14262; CHECK: br %r14263entry:264 %and = and i32 %a, 101265 %cmp = icmp eq i32 %and, 101266 br i1 %cmp, label %exit, label %store267 268store:269 store i32 1, ptr@g270 br label %exit271 272exit:273 ret void274}275 276; Check that we can use TMLL for inequality comparisons with the mask.277define void @f15(i32 %a) {278; CHECK-LABEL: f15:279; CHECK: tmll %r2, 65519280; CHECK: bnor %r14281; CHECK: br %r14282entry:283 %and = and i32 %a, 65519284 %cmp = icmp ne i32 %and, 65519285 br i1 %cmp, label %exit, label %store286 287store:288 store i32 1, ptr@g289 br label %exit290 291exit:292 ret void293}294 295; Check that we can use TMLL for LT comparisons that are equivalent296; to inequality comparisons with the mask.297define void @f16(i32 %a) {298; CHECK-LABEL: f16:299; CHECK: tmll %r2, 130300; CHECK: bnor %r14301; CHECK: br %r14302entry:303 %and = and i32 %a, 130304 %cmp = icmp ult i32 %and, 129305 br i1 %cmp, label %exit, label %store306 307store:308 store i32 1, ptr@g309 br label %exit310 311exit:312 ret void313}314 315; ...same again with LE.316define void @f17(i32 %a) {317; CHECK-LABEL: f17:318; CHECK: tmll %r2, 130319; CHECK: bnor %r14320; CHECK: br %r14321entry:322 %and = and i32 %a, 130323 %cmp = icmp ule i32 %and, 128324 br i1 %cmp, label %exit, label %store325 326store:327 store i32 1, ptr@g328 br label %exit329 330exit:331 ret void332}333 334; Check that we can use TMLL for GE comparisons that are equivalent335; to equality comparisons with the mask.336define void @f18(i32 %a) {337; CHECK-LABEL: f18:338; CHECK: tmll %r2, 194339; CHECK: bor %r14340; CHECK: br %r14341entry:342 %and = and i32 %a, 194343 %cmp = icmp uge i32 %and, 193344 br i1 %cmp, label %exit, label %store345 346store:347 store i32 1, ptr@g348 br label %exit349 350exit:351 ret void352}353 354; ...same again for GT.355define void @f19(i32 %a) {356; CHECK-LABEL: f19:357; CHECK: tmll %r2, 194358; CHECK: bor %r14359; CHECK: br %r14360entry:361 %and = and i32 %a, 194362 %cmp = icmp ugt i32 %and, 192363 br i1 %cmp, label %exit, label %store364 365store:366 store i32 1, ptr@g367 br label %exit368 369exit:370 ret void371}372 373; Check that we can use TMLL for equality comparisons for the low bit374; when the mask has two bits.375define void @f20(i32 %a) {376; CHECK-LABEL: f20:377; CHECK: tmll %r2, 20378; CHECK: blr %r14379; CHECK: br %r14380entry:381 %and = and i32 %a, 20382 %cmp = icmp eq i32 %and, 4383 br i1 %cmp, label %exit, label %store384 385store:386 store i32 1, ptr@g387 br label %exit388 389exit:390 ret void391}392 393; Check that we can use TMLL for inequality comparisons for the low bit394; when the mask has two bits.395define void @f21(i32 %a) {396; CHECK-LABEL: f21:397; CHECK: tmll %r2, 20398; CHECK: bnlr %r14399; CHECK: br %r14400entry:401 %and = and i32 %a, 20402 %cmp = icmp ne i32 %and, 4403 br i1 %cmp, label %exit, label %store404 405store:406 store i32 1, ptr@g407 br label %exit408 409exit:410 ret void411}412 413; Check that we can use TMLL for equality comparisons for the high bit414; when the mask has two bits.415define void @f22(i32 %a) {416; CHECK-LABEL: f22:417; CHECK: tmll %r2, 20418; CHECK: bhr %r14419; CHECK: br %r14420entry:421 %and = and i32 %a, 20422 %cmp = icmp eq i32 %and, 16423 br i1 %cmp, label %exit, label %store424 425store:426 store i32 1, ptr@g427 br label %exit428 429exit:430 ret void431}432 433; Check that we can use TMLL for inequality comparisons for the high bit434; when the mask has two bits.435define void @f23(i32 %a) {436; CHECK-LABEL: f23:437; CHECK: tmll %r2, 20438; CHECK: bnhr %r14439; CHECK: br %r14440entry:441 %and = and i32 %a, 20442 %cmp = icmp ne i32 %and, 16443 br i1 %cmp, label %exit, label %store444 445store:446 store i32 1, ptr@g447 br label %exit448 449exit:450 ret void451}452 453; Check that we can fold an SHL into a TMxx mask.454define void @f24(i32 %a) {455; CHECK-LABEL: f24:456; CHECK: tmll %r2, 255457; CHECK: bner %r14458; CHECK: br %r14459entry:460 %shl = shl i32 %a, 12461 %and = and i32 %shl, 1044480462 %cmp = icmp ne i32 %and, 0463 br i1 %cmp, label %exit, label %store464 465store:466 store i32 1, ptr@g467 br label %exit468 469exit:470 ret void471}472 473; Check that we can fold an SHR into a TMxx mask.474define void @f25(i32 %a) {475; CHECK-LABEL: f25:476; CHECK: tmlh %r2, 512477; CHECK: bner %r14478; CHECK: br %r14479entry:480 %shr = lshr i32 %a, 25481 %and = and i32 %shr, 1482 %cmp = icmp ne i32 %and, 0483 br i1 %cmp, label %exit, label %store484 485store:486 store i32 1, ptr@g487 br label %exit488 489exit:490 ret void491}492