1*9880d681SAndroid Build Coastguard Worker; Test moves of integers to 8-byte memory locations. 2*9880d681SAndroid Build Coastguard Worker; 3*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s 4*9880d681SAndroid Build Coastguard Worker 5*9880d681SAndroid Build Coastguard Worker; Check moves of zero. 6*9880d681SAndroid Build Coastguard Workerdefine void @f1(i64 *%a) { 7*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f1: 8*9880d681SAndroid Build Coastguard Worker; CHECK: mvghi 0(%r2), 0 9*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14 10*9880d681SAndroid Build Coastguard Worker store i64 0, i64 *%a 11*9880d681SAndroid Build Coastguard Worker ret void 12*9880d681SAndroid Build Coastguard Worker} 13*9880d681SAndroid Build Coastguard Worker 14*9880d681SAndroid Build Coastguard Worker; Check the high end of the signed 16-bit range. 15*9880d681SAndroid Build Coastguard Workerdefine void @f2(i64 *%a) { 16*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f2: 17*9880d681SAndroid Build Coastguard Worker; CHECK: mvghi 0(%r2), 32767 18*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14 19*9880d681SAndroid Build Coastguard Worker store i64 32767, i64 *%a 20*9880d681SAndroid Build Coastguard Worker ret void 21*9880d681SAndroid Build Coastguard Worker} 22*9880d681SAndroid Build Coastguard Worker 23*9880d681SAndroid Build Coastguard Worker; Check the next value up, which can't use MVGHI. 24*9880d681SAndroid Build Coastguard Workerdefine void @f3(i64 *%a) { 25*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f3: 26*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: mvghi 27*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14 28*9880d681SAndroid Build Coastguard Worker store i64 32768, i64 *%a 29*9880d681SAndroid Build Coastguard Worker ret void 30*9880d681SAndroid Build Coastguard Worker} 31*9880d681SAndroid Build Coastguard Worker 32*9880d681SAndroid Build Coastguard Worker; Check moves of -1. 33*9880d681SAndroid Build Coastguard Workerdefine void @f4(i64 *%a) { 34*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f4: 35*9880d681SAndroid Build Coastguard Worker; CHECK: mvghi 0(%r2), -1 36*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14 37*9880d681SAndroid Build Coastguard Worker store i64 -1, i64 *%a 38*9880d681SAndroid Build Coastguard Worker ret void 39*9880d681SAndroid Build Coastguard Worker} 40*9880d681SAndroid Build Coastguard Worker 41*9880d681SAndroid Build Coastguard Worker; Check the low end of the MVGHI range. 42*9880d681SAndroid Build Coastguard Workerdefine void @f5(i64 *%a) { 43*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f5: 44*9880d681SAndroid Build Coastguard Worker; CHECK: mvghi 0(%r2), -32768 45*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14 46*9880d681SAndroid Build Coastguard Worker store i64 -32768, i64 *%a 47*9880d681SAndroid Build Coastguard Worker ret void 48*9880d681SAndroid Build Coastguard Worker} 49*9880d681SAndroid Build Coastguard Worker 50*9880d681SAndroid Build Coastguard Worker; Check the next value down, which can't use MVGHI. 51*9880d681SAndroid Build Coastguard Workerdefine void @f6(i64 *%a) { 52*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f6: 53*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: mvghi 54*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14 55*9880d681SAndroid Build Coastguard Worker store i64 -32769, i64 *%a 56*9880d681SAndroid Build Coastguard Worker ret void 57*9880d681SAndroid Build Coastguard Worker} 58*9880d681SAndroid Build Coastguard Worker 59*9880d681SAndroid Build Coastguard Worker; Check the high end of the MVGHI range. 60*9880d681SAndroid Build Coastguard Workerdefine void @f7(i64 *%a) { 61*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f7: 62*9880d681SAndroid Build Coastguard Worker; CHECK: mvghi 4088(%r2), 42 63*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14 64*9880d681SAndroid Build Coastguard Worker %ptr = getelementptr i64, i64 *%a, i64 511 65*9880d681SAndroid Build Coastguard Worker store i64 42, i64 *%ptr 66*9880d681SAndroid Build Coastguard Worker ret void 67*9880d681SAndroid Build Coastguard Worker} 68*9880d681SAndroid Build Coastguard Worker 69*9880d681SAndroid Build Coastguard Worker; Check the next doubleword up, which is out of range. We prefer STG 70*9880d681SAndroid Build Coastguard Worker; in that case. 71*9880d681SAndroid Build Coastguard Workerdefine void @f8(i64 *%a) { 72*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f8: 73*9880d681SAndroid Build Coastguard Worker; CHECK: lghi [[TMP:%r[0-5]]], 42 74*9880d681SAndroid Build Coastguard Worker; CHECK: stg [[TMP]], 4096(%r2) 75*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14 76*9880d681SAndroid Build Coastguard Worker %ptr = getelementptr i64, i64 *%a, i64 512 77*9880d681SAndroid Build Coastguard Worker store i64 42, i64 *%ptr 78*9880d681SAndroid Build Coastguard Worker ret void 79*9880d681SAndroid Build Coastguard Worker} 80*9880d681SAndroid Build Coastguard Worker 81*9880d681SAndroid Build Coastguard Worker; Check negative displacements, for which we again prefer STG. 82*9880d681SAndroid Build Coastguard Workerdefine void @f9(i64 *%a) { 83*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f9: 84*9880d681SAndroid Build Coastguard Worker; CHECK: lghi [[TMP:%r[0-5]]], 42 85*9880d681SAndroid Build Coastguard Worker; CHECK: stg [[TMP]], -8(%r2) 86*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14 87*9880d681SAndroid Build Coastguard Worker %ptr = getelementptr i64, i64 *%a, i64 -1 88*9880d681SAndroid Build Coastguard Worker store i64 42, i64 *%ptr 89*9880d681SAndroid Build Coastguard Worker ret void 90*9880d681SAndroid Build Coastguard Worker} 91*9880d681SAndroid Build Coastguard Worker 92*9880d681SAndroid Build Coastguard Worker; Check that MVGHI does not allow an index. 93*9880d681SAndroid Build Coastguard Workerdefine void @f10(i64 %src, i64 %index) { 94*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f10: 95*9880d681SAndroid Build Coastguard Worker; CHECK: lghi [[TMP:%r[0-5]]], 42 96*9880d681SAndroid Build Coastguard Worker; CHECK: stg [[TMP]], 0({{%r2,%r3|%r3,%r2}}) 97*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14 98*9880d681SAndroid Build Coastguard Worker %add = add i64 %src, %index 99*9880d681SAndroid Build Coastguard Worker %ptr = inttoptr i64 %add to i64 * 100*9880d681SAndroid Build Coastguard Worker store i64 42, i64 *%ptr 101*9880d681SAndroid Build Coastguard Worker ret void 102*9880d681SAndroid Build Coastguard Worker} 103