brintos

brintos / llvm-project-archived public Read only

0
0
Text · 11.8 KiB · 989f10e Raw
332 lines · plain
1; Test the handling of base + index + displacement addresses for large frames,2; in cases where both 12-bit and 20-bit displacements are allowed.3; The tests here assume z10 register pressure, without the high words4; being available.5;6; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z10 | \7; RUN:   FileCheck -check-prefix=CHECK-NOFP %s8; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z10 -frame-pointer=all | \9; RUN:   FileCheck -check-prefix=CHECK-FP %s10 11; This file tests what happens when a displacement is converted from12; being relative to the start of a frame object to being relative to13; the frame itself.  In some cases the test is only possible if two14; objects are allocated.15;16; Rather than rely on a particular order for those objects, the tests17; instead allocate two objects of the same size and apply the test to18; both of them.  For consistency, all tests follow this model, even if19; one object would actually be enough.20 21; First check the highest offset that is in range of the 12-bit form.22;23; The last in-range doubleword offset is 4088.  Since the frame has two24; emergency spill slots at 160(%r15), the amount that we need to allocate25; in order to put another object at offset 4088 is 4088 - 176 = 3912 bytes.26define void @f1(i8 %byte) {27; CHECK-NOFP-LABEL: f1:28; CHECK-NOFP: stc %r2, 4095(%r15)29; CHECK-NOFP: br %r1430;31; CHECK-FP-LABEL: f1:32; CHECK-FP: stc %r2, 4095(%r11)33; CHECK-FP: br %r1434  %region1 = alloca [3912 x i8], align 835  %region2 = alloca [3912 x i8], align 836  %ptr1 = getelementptr inbounds [3912 x i8], ptr %region1, i64 0, i64 737  %ptr2 = getelementptr inbounds [3912 x i8], ptr %region2, i64 0, i64 738  store volatile i8 %byte, ptr %ptr139  store volatile i8 %byte, ptr %ptr240  ret void41}42 43; Test the first offset that is out-of-range of the 12-bit form.44define void @f2(i8 %byte) {45; CHECK-NOFP-LABEL: f2:46; CHECK-NOFP: stcy %r2, 4096(%r15)47; CHECK-NOFP: br %r1448;49; CHECK-FP-LABEL: f2:50; CHECK-FP: stcy %r2, 4096(%r11)51; CHECK-FP: br %r1452  %region1 = alloca [3912 x i8], align 853  %region2 = alloca [3912 x i8], align 854  %ptr1 = getelementptr inbounds [3912 x i8], ptr %region1, i64 0, i64 855  %ptr2 = getelementptr inbounds [3912 x i8], ptr %region2, i64 0, i64 856  store volatile i8 %byte, ptr %ptr157  store volatile i8 %byte, ptr %ptr258  ret void59}60 61; Test the last offset that is in range of the 20-bit form.62;63; The last in-range doubleword offset is 524280, so by the same reasoning64; as above, we need to allocate objects of 524280 - 176 = 524104 bytes.65define void @f3(i8 %byte) {66; CHECK-NOFP-LABEL: f3:67; CHECK-NOFP: stcy %r2, 524287(%r15)68; CHECK-NOFP: br %r1469;70; CHECK-FP-LABEL: f3:71; CHECK-FP: stcy %r2, 524287(%r11)72; CHECK-FP: br %r1473  %region1 = alloca [524104 x i8], align 874  %region2 = alloca [524104 x i8], align 875  %ptr1 = getelementptr inbounds [524104 x i8], ptr %region1, i64 0, i64 776  %ptr2 = getelementptr inbounds [524104 x i8], ptr %region2, i64 0, i64 777  store volatile i8 %byte, ptr %ptr178  store volatile i8 %byte, ptr %ptr279  ret void80}81 82; Test the first out-of-range offset.  We can't use an index register here,83; and the offset is also out of LAY's range, so expect a constant load84; followed by an addition.85define void @f4(i8 %byte) {86; CHECK-NOFP-LABEL: f4:87; CHECK-NOFP: llilh %r1, 888; CHECK-NOFP: stc %r2, 0(%r1,%r15)89; CHECK-NOFP: br %r1490;91; CHECK-FP-LABEL: f4:92; CHECK-FP: llilh %r1, 893; CHECK-FP: stc %r2, 0(%r1,%r11)94; CHECK-FP: br %r1495  %region1 = alloca [524104 x i8], align 896  %region2 = alloca [524104 x i8], align 897  %ptr1 = getelementptr inbounds [524104 x i8], ptr %region1, i64 0, i64 898  %ptr2 = getelementptr inbounds [524104 x i8], ptr %region2, i64 0, i64 899  store volatile i8 %byte, ptr %ptr1100  store volatile i8 %byte, ptr %ptr2101  ret void102}103 104; Add 4095 to the previous offset, to test the other end of the STC range.105; The instruction will actually be STCY before frame lowering.106define void @f5(i8 %byte) {107; CHECK-NOFP-LABEL: f5:108; CHECK-NOFP: llilh %r1, 8109; CHECK-NOFP: stc %r2, 4095(%r1,%r15)110; CHECK-NOFP: br %r14111;112; CHECK-FP-LABEL: f5:113; CHECK-FP: llilh %r1, 8114; CHECK-FP: stc %r2, 4095(%r1,%r11)115; CHECK-FP: br %r14116  %region1 = alloca [524104 x i8], align 8117  %region2 = alloca [524104 x i8], align 8118  %ptr1 = getelementptr inbounds [524104 x i8], ptr %region1, i64 0, i64 4103119  %ptr2 = getelementptr inbounds [524104 x i8], ptr %region2, i64 0, i64 4103120  store volatile i8 %byte, ptr %ptr1121  store volatile i8 %byte, ptr %ptr2122  ret void123}124 125; Test the next offset after that, which uses STCY instead of STC.126define void @f6(i8 %byte) {127; CHECK-NOFP-LABEL: f6:128; CHECK-NOFP: llilh %r1, 8129; CHECK-NOFP: stcy %r2, 4096(%r1,%r15)130; CHECK-NOFP: br %r14131;132; CHECK-FP-LABEL: f6:133; CHECK-FP: llilh %r1, 8134; CHECK-FP: stcy %r2, 4096(%r1,%r11)135; CHECK-FP: br %r14136  %region1 = alloca [524104 x i8], align 8137  %region2 = alloca [524104 x i8], align 8138  %ptr1 = getelementptr inbounds [524104 x i8], ptr %region1, i64 0, i64 4104139  %ptr2 = getelementptr inbounds [524104 x i8], ptr %region2, i64 0, i64 4104140  store volatile i8 %byte, ptr %ptr1141  store volatile i8 %byte, ptr %ptr2142  ret void143}144 145; Now try an offset of 524287 from the start of the object, with the146; object being at offset 1048576 (1 << 20).  The backend prefers to create147; anchors 0x10000 bytes apart, so that the high part can be loaded using148; LLILH while still using STC in more cases than 0x40000 anchors would.149define void @f7(i8 %byte) {150; CHECK-NOFP-LABEL: f7:151; CHECK-NOFP: llilh %r1, 23152; CHECK-NOFP: stcy %r2, 65535(%r1,%r15)153; CHECK-NOFP: br %r14154;155; CHECK-FP-LABEL: f7:156; CHECK-FP: llilh %r1, 23157; CHECK-FP: stcy %r2, 65535(%r1,%r11)158; CHECK-FP: br %r14159  %region1 = alloca [1048400 x i8], align 8160  %region2 = alloca [1048400 x i8], align 8161  %ptr1 = getelementptr inbounds [1048400 x i8], ptr %region1, i64 0, i64 524287162  %ptr2 = getelementptr inbounds [1048400 x i8], ptr %region2, i64 0, i64 524287163  store volatile i8 %byte, ptr %ptr1164  store volatile i8 %byte, ptr %ptr2165  ret void166}167 168; Keep the object-relative offset the same but bump the size of the169; objects by one doubleword.170define void @f8(i8 %byte) {171; CHECK-NOFP-LABEL: f8:172; CHECK-NOFP: llilh %r1, 24173; CHECK-NOFP: stc %r2, 7(%r1,%r15)174; CHECK-NOFP: br %r14175;176; CHECK-FP-LABEL: f8:177; CHECK-FP: llilh %r1, 24178; CHECK-FP: stc %r2, 7(%r1,%r11)179; CHECK-FP: br %r14180  %region1 = alloca [1048408 x i8], align 8181  %region2 = alloca [1048408 x i8], align 8182  %ptr1 = getelementptr inbounds [1048408 x i8], ptr %region1, i64 0, i64 524287183  %ptr2 = getelementptr inbounds [1048408 x i8], ptr %region2, i64 0, i64 524287184  store volatile i8 %byte, ptr %ptr1185  store volatile i8 %byte, ptr %ptr2186  ret void187}188 189; Check a case where the original displacement is out of range.  The backend190; should force separate address logic from the outset.  We don't yet do any191; kind of anchor optimization, so there should be no offset on the STC itself.192;193; Before frame lowering this is an LA followed by the AGFI seen below.194; The LA then gets lowered into the LLILH/LA form.  The exact sequence195; isn't that important though.196define void @f9(i8 %byte) {197; CHECK-NOFP-LABEL: f9:198; CHECK-NOFP: llilh [[R1:%r[1-5]]], 16199; CHECK-NOFP: la [[R2:%r[1-5]]], 8([[R1]],%r15)200; CHECK-NOFP: agfi [[R2]], 524288201; CHECK-NOFP: stc %r2, 0([[R2]])202; CHECK-NOFP: br %r14203;204; CHECK-FP-LABEL: f9:205; CHECK-FP: llilh [[R1:%r[1-5]]], 16206; CHECK-FP: la [[R2:%r[1-5]]], 8([[R1]],%r11)207; CHECK-FP: agfi [[R2]], 524288208; CHECK-FP: stc %r2, 0([[R2]])209; CHECK-FP: br %r14210  %region1 = alloca [1048408 x i8], align 8211  %region2 = alloca [1048408 x i8], align 8212  %ptr1 = getelementptr inbounds [1048408 x i8], ptr %region1, i64 0, i64 524288213  %ptr2 = getelementptr inbounds [1048408 x i8], ptr %region2, i64 0, i64 524288214  store volatile i8 %byte, ptr %ptr1215  store volatile i8 %byte, ptr %ptr2216  ret void217}218 219; Repeat f4 in a case that needs the emergency spill slots (because all220; call-clobbered registers are live and no call-saved ones have been221; allocated).222define void @f10(ptr %vptr, i8 %byte) {223; CHECK-NOFP-LABEL: f10:224; CHECK-NOFP: stg [[REGISTER:%r[1-9][0-4]?]], [[OFFSET:160|168]](%r15)225; CHECK-NOFP: llilh [[REGISTER]], 8226; CHECK-NOFP: stc %r3, 0([[REGISTER]],%r15)227; CHECK-NOFP: lg [[REGISTER]], [[OFFSET]](%r15)228; CHECK-NOFP: br %r14229;230; CHECK-FP-LABEL: f10:231; CHECK-FP: stg [[REGISTER:%r[1-9][0-4]?]], [[OFFSET:160|168]](%r11)232; CHECK-FP: llilh [[REGISTER]], 8233; CHECK-FP: stc %r3, 0([[REGISTER]],%r11)234; CHECK-FP: lg [[REGISTER]], [[OFFSET]](%r11)235; CHECK-FP: br %r14236  %i0 = load volatile i32, ptr %vptr237  %i1 = load volatile i32, ptr %vptr238  %i4 = load volatile i32, ptr %vptr239  %i5 = load volatile i32, ptr %vptr240  %region1 = alloca [524104 x i8], align 8241  %region2 = alloca [524104 x i8], align 8242  %ptr1 = getelementptr inbounds [524104 x i8], ptr %region1, i64 0, i64 8243  %ptr2 = getelementptr inbounds [524104 x i8], ptr %region2, i64 0, i64 8244  store volatile i8 %byte, ptr %ptr1245  store volatile i8 %byte, ptr %ptr2246  store volatile i32 %i0, ptr %vptr247  store volatile i32 %i1, ptr %vptr248  store volatile i32 %i4, ptr %vptr249  store volatile i32 %i5, ptr %vptr250  ret void251}252 253; And again with maximum register pressure.  The only spill slots that the254; NOFP case needs are the emergency ones, so the offsets are the same as for f4.255; However, the FP case uses %r11 as the frame pointer and must therefore256; spill a second register.  This leads to an extra displacement of 8.257define void @f11(ptr %vptr, i8 %byte) {258; CHECK-NOFP-LABEL: f11:259; CHECK-NOFP: stmg %r6, %r15,260; CHECK-NOFP: stg [[REGISTER:%r[1-9][0-4]?]], [[OFFSET:160|168]](%r15)261; CHECK-NOFP: llilh [[REGISTER]], 8262; CHECK-NOFP: stc %r3, 0([[REGISTER]],%r15)263; CHECK-NOFP: lg [[REGISTER]], [[OFFSET]](%r15)264; CHECK-NOFP: lmg %r6, %r15,265; CHECK-NOFP: br %r14266;267; CHECK-FP-LABEL: f11:268; CHECK-FP: stmg %r6, %r15,269; CHECK-FP: stg [[REGISTER:%r[1-9][0-4]?]], [[OFFSET:160|168]](%r11)270; CHECK-FP: llilh [[REGISTER]], 8271; CHECK-FP: stc %r3, 8([[REGISTER]],%r11)272; CHECK-FP: lg [[REGISTER]], [[OFFSET]](%r11)273; CHECK-FP: lmg %r6, %r15,274; CHECK-FP: br %r14275  %i0 = load volatile i32, ptr %vptr276  %i1 = load volatile i32, ptr %vptr277  %i4 = load volatile i32, ptr %vptr278  %i5 = load volatile i32, ptr %vptr279  %i6 = load volatile i32, ptr %vptr280  %i7 = load volatile i32, ptr %vptr281  %i8 = load volatile i32, ptr %vptr282  %i9 = load volatile i32, ptr %vptr283  %i10 = load volatile i32, ptr %vptr284  %i11 = load volatile i32, ptr %vptr285  %i12 = load volatile i32, ptr %vptr286  %i13 = load volatile i32, ptr %vptr287  %i14 = load volatile i32, ptr %vptr288  %region1 = alloca [524104 x i8], align 8289  %region2 = alloca [524104 x i8], align 8290  %ptr1 = getelementptr inbounds [524104 x i8], ptr %region1, i64 0, i64 8291  %ptr2 = getelementptr inbounds [524104 x i8], ptr %region2, i64 0, i64 8292  store volatile i8 %byte, ptr %ptr1293  store volatile i8 %byte, ptr %ptr2294  store volatile i32 %i0, ptr %vptr295  store volatile i32 %i1, ptr %vptr296  store volatile i32 %i4, ptr %vptr297  store volatile i32 %i5, ptr %vptr298  store volatile i32 %i6, ptr %vptr299  store volatile i32 %i7, ptr %vptr300  store volatile i32 %i8, ptr %vptr301  store volatile i32 %i9, ptr %vptr302  store volatile i32 %i10, ptr %vptr303  store volatile i32 %i11, ptr %vptr304  store volatile i32 %i12, ptr %vptr305  store volatile i32 %i13, ptr %vptr306  store volatile i32 %i14, ptr %vptr307  ret void308}309 310; Repeat f4 in a case where the index register is already occupied.311define void @f12(i8 %byte, i64 %index) {312; CHECK-NOFP-LABEL: f12:313; CHECK-NOFP: llilh %r1, 8314; CHECK-NOFP: la %r1, 0(%r1,%r15)315; CHECK-NOFP: stc %r2, 0(%r3,%r1)316; CHECK-NOFP: br %r14317;318; CHECK-FP-LABEL: f12:319; CHECK-FP: llilh %r1, 8320; CHECK-FP: la %r1, 0(%r1,%r11)321; CHECK-FP: stc %r2, 0(%r3,%r1)322; CHECK-FP: br %r14323  %region1 = alloca [524104 x i8], align 8324  %region2 = alloca [524104 x i8], align 8325  %index1 = add i64 %index, 8326  %ptr1 = getelementptr inbounds [524104 x i8], ptr %region1, i64 0, i64 %index1327  %ptr2 = getelementptr inbounds [524104 x i8], ptr %region2, i64 0, i64 %index1328  store volatile i8 %byte, ptr %ptr1329  store volatile i8 %byte, ptr %ptr2330  ret void331}332