1; Test LOCHI and LOCGHI. 2; 3; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 -verify-machineinstrs | FileCheck %s 4 5define i32 @f1(i32 %x) { 6; CHECK-LABEL: f1: 7; CHECK: chi %r2, 0 8; CHECK: lhi %r2, 0 9; CHECK: lochilh %r2, 42 10; CHECK: br %r14 11 %cond = icmp ne i32 %x, 0 12 %res = select i1 %cond, i32 42, i32 0 13 ret i32 %res 14} 15 16define i32 @f2(i32 %x, i32 %y) { 17; CHECK-LABEL: f2: 18; CHECK: chi %r2, 0 19; CHECK: lochilh %r3, 42 20; CHECK: br %r14 21 %cond = icmp ne i32 %x, 0 22 %res = select i1 %cond, i32 42, i32 %y 23 ret i32 %res 24} 25 26define i32 @f3(i32 %x, i32 %y) { 27; CHECK-LABEL: f3: 28; CHECK: chi %r2, 0 29; CHECK: lochie %r3, 42 30; CHECK: br %r14 31 %cond = icmp ne i32 %x, 0 32 %res = select i1 %cond, i32 %y, i32 42 33 ret i32 %res 34} 35 36define i64 @f4(i64 %x) { 37; CHECK-LABEL: f4: 38; CHECK: cghi %r2, 0 39; CHECK: lghi %r2, 0 40; CHECK: locghilh %r2, 42 41; CHECK: br %r14 42 %cond = icmp ne i64 %x, 0 43 %res = select i1 %cond, i64 42, i64 0 44 ret i64 %res 45} 46 47define i64 @f5(i64 %x, i64 %y) { 48; CHECK-LABEL: f5: 49; CHECK: cghi %r2, 0 50; CHECK: locghilh %r3, 42 51; CHECK: br %r14 52 %cond = icmp ne i64 %x, 0 53 %res = select i1 %cond, i64 42, i64 %y 54 ret i64 %res 55} 56 57define i64 @f6(i64 %x, i64 %y) { 58; CHECK-LABEL: f6: 59; CHECK: cghi %r2, 0 60; CHECK: locghie %r3, 42 61; CHECK: br %r14 62 %cond = icmp ne i64 %x, 0 63 %res = select i1 %cond, i64 %y, i64 42 64 ret i64 %res 65} 66 67; Check that we also get LOCHI as a result of early if-conversion. 68define i32 @f7(i32 %x, i32 %y) { 69; CHECK-LABEL: f7: 70; CHECK: chi %r2, 0 71; CHECK: lochie %r3, 42 72; CHECK: br %r14 73entry: 74 %cond = icmp ne i32 %x, 0 75 br i1 %cond, label %if.then, label %return 76 77if.then: 78 br label %return 79 80return: 81 %res = phi i32 [ %y, %if.then ], [ 42, %entry ] 82 ret i32 %res 83} 84 85; ... and the same for LOCGHI. 86define i64 @f8(i64 %x, i64 %y) { 87; CHECK-LABEL: f8: 88; CHECK: cghi %r2, 0 89; CHECK: locghie %r3, 42 90; CHECK: br %r14 91entry: 92 %cond = icmp ne i64 %x, 0 93 br i1 %cond, label %if.then, label %return 94 95if.then: 96 br label %return 97 98return: 99 %res = phi i64 [ %y, %if.then ], [ 42, %entry ] 100 ret i64 %res 101} 102 103; Check that inverting the condition works as well. 104define i32 @f9(i32 %x, i32 %y) { 105; CHECK-LABEL: f9: 106; CHECK: chi %r2, 0 107; CHECK: lochilh %r3, 42 108; CHECK: br %r14 109entry: 110 %cond = icmp ne i32 %x, 0 111 br i1 %cond, label %if.then, label %return 112 113if.then: 114 br label %return 115 116return: 117 %res = phi i32 [ 42, %if.then ], [ %y, %entry ] 118 ret i32 %res 119} 120 121; ... and the same for LOCGHI. 122define i64 @f10(i64 %x, i64 %y) { 123; CHECK-LABEL: f10: 124; CHECK: cghi %r2, 0 125; CHECK: locghilh %r3, 42 126; CHECK: br %r14 127entry: 128 %cond = icmp ne i64 %x, 0 129 br i1 %cond, label %if.then, label %return 130 131if.then: 132 br label %return 133 134return: 135 %res = phi i64 [ 42, %if.then ], [ %y, %entry ] 136 ret i64 %res 137} 138 139