brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.9 KiB · 362d7cc Raw
144 lines · plain
1; Test LOCHI and LOCGHI.2;3; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 -verify-machineinstrs | FileCheck %s4;5; Run the test again to make sure it still works the same even6; in the presence of the select instructions.7; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z15 -verify-machineinstrs | FileCheck %s8 9 10define i32 @f1(i32 %x) {11; CHECK-LABEL: f1:12; CHECK: chi %r2, 013; CHECK: lhi %r2, 014; CHECK: lochilh %r2, 4215; CHECK: br %r1416  %cond = icmp ne i32 %x, 017  %res = select i1 %cond, i32 42, i32 018  ret i32 %res19}20 21define i32 @f2(i32 %x, i32 %y) {22; CHECK-LABEL: f2:23; CHECK: chi %r2, 024; CHECK: lochilh %r3, 4225; CHECK: br %r1426  %cond = icmp ne i32 %x, 027  %res = select i1 %cond, i32 42, i32 %y28  ret i32 %res29}30 31define i32 @f3(i32 %x, i32 %y) {32; CHECK-LABEL: f3:33; CHECK: chi %r2, 034; CHECK: lochie %r3, 4235; CHECK: br %r1436  %cond = icmp ne i32 %x, 037  %res = select i1 %cond, i32 %y, i32 4238  ret i32 %res39}40 41define i64 @f4(i64 %x) {42; CHECK-LABEL: f4:43; CHECK: cghi %r2, 044; CHECK: lghi %r2, 045; CHECK: locghilh %r2, 4246; CHECK: br %r1447  %cond = icmp ne i64 %x, 048  %res = select i1 %cond, i64 42, i64 049  ret i64 %res50}51 52define i64 @f5(i64 %x, i64 %y) {53; CHECK-LABEL: f5:54; CHECK: cghi %r2, 055; CHECK: locghilh %r3, 4256; CHECK: br %r1457  %cond = icmp ne i64 %x, 058  %res = select i1 %cond, i64 42, i64 %y59  ret i64 %res60}61 62define i64 @f6(i64 %x, i64 %y) {63; CHECK-LABEL: f6:64; CHECK: cghi %r2, 065; CHECK: locghie %r3, 4266; CHECK: br %r1467  %cond = icmp ne i64 %x, 068  %res = select i1 %cond, i64 %y, i64 4269  ret i64 %res70}71 72; Check that we also get LOCHI as a result of early if-conversion.73define i32 @f7(i32 %x, i32 %y) {74; CHECK-LABEL: f7:75; CHECK: chi %r2, 076; CHECK: lochie %r3, 4277; CHECK: br %r1478entry:79  %cond = icmp ne i32 %x, 080  br i1 %cond, label %if.then, label %return81 82if.then:83  br label %return84 85return:86  %res = phi i32 [ %y, %if.then ], [ 42, %entry ]87  ret i32 %res88}89 90; ... and the same for LOCGHI.91define i64 @f8(i64 %x, i64 %y) {92; CHECK-LABEL: f8:93; CHECK: cghi %r2, 094; CHECK: locghie %r3, 4295; CHECK: br %r1496entry:97  %cond = icmp ne i64 %x, 098  br i1 %cond, label %if.then, label %return99 100if.then:101  br label %return102 103return:104  %res = phi i64 [ %y, %if.then ], [ 42, %entry ]105  ret i64 %res106}107 108; Check that inverting the condition works as well.109define i32 @f9(i32 %x, i32 %y) {110; CHECK-LABEL: f9:111; CHECK: chi %r2, 0112; CHECK: lochilh %r3, 42113; CHECK: br %r14114entry:115  %cond = icmp ne i32 %x, 0116  br i1 %cond, label %if.then, label %return117 118if.then:119  br label %return120 121return:122  %res = phi i32 [ 42, %if.then ], [ %y, %entry ]123  ret i32 %res124}125 126; ... and the same for LOCGHI.127define i64 @f10(i64 %x, i64 %y) {128; CHECK-LABEL: f10:129; CHECK: cghi %r2, 0130; CHECK: locghilh %r3, 42131; CHECK: br %r14132entry:133  %cond = icmp ne i64 %x, 0134  br i1 %cond, label %if.then, label %return135 136if.then:137  br label %return138 139return:140  %res = phi i64 [ 42, %if.then ], [ %y, %entry ]141  ret i64 %res142}143 144