1; RUN: llc < %s -mtriple=arm64-eabi -enable-misched=false -aarch64-enable-stp-suppress=false -verify-machineinstrs | FileCheck %s 2 3; The next set of tests makes sure we can combine the second instruction into 4; the first. 5 6; CHECK-LABEL: stp_int_aa 7; CHECK: stp w0, w1, [x2] 8; CHECK: ldr w0, [x2, #8] 9; CHECK: ret 10define i32 @stp_int_aa(i32 %a, i32 %b, ptr nocapture %p) nounwind { 11 store i32 %a, ptr %p, align 4 12 %ld.ptr = getelementptr inbounds i32, ptr %p, i64 2 13 %tmp = load i32, ptr %ld.ptr, align 4 14 %add.ptr = getelementptr inbounds i32, ptr %p, i64 1 15 store i32 %b, ptr %add.ptr, align 4 16 ret i32 %tmp 17} 18 19; CHECK-LABEL: stp_long_aa 20; CHECK: stp x0, x1, [x2] 21; CHECK: ldr x0, [x2, #16] 22; CHECK: ret 23define i64 @stp_long_aa(i64 %a, i64 %b, ptr nocapture %p) nounwind { 24 store i64 %a, ptr %p, align 8 25 %ld.ptr = getelementptr inbounds i64, ptr %p, i64 2 26 %tmp = load i64, ptr %ld.ptr, align 4 27 %add.ptr = getelementptr inbounds i64, ptr %p, i64 1 28 store i64 %b, ptr %add.ptr, align 8 29 ret i64 %tmp 30} 31 32; CHECK-LABEL: stp_float_aa 33; CHECK: stp s0, s1, [x0] 34; CHECK: ldr s0, [x0, #8] 35; CHECK: ret 36define float @stp_float_aa(float %a, float %b, ptr nocapture %p) nounwind { 37 store float %a, ptr %p, align 4 38 %ld.ptr = getelementptr inbounds float, ptr %p, i64 2 39 %tmp = load float, ptr %ld.ptr, align 4 40 %add.ptr = getelementptr inbounds float, ptr %p, i64 1 41 store float %b, ptr %add.ptr, align 4 42 ret float %tmp 43} 44 45; CHECK-LABEL: stp_double_aa 46; CHECK: stp d0, d1, [x0] 47; CHECK: ldr d0, [x0, #16] 48; CHECK: ret 49define double @stp_double_aa(double %a, double %b, ptr nocapture %p) nounwind { 50 store double %a, ptr %p, align 8 51 %ld.ptr = getelementptr inbounds double, ptr %p, i64 2 52 %tmp = load double, ptr %ld.ptr, align 4 53 %add.ptr = getelementptr inbounds double, ptr %p, i64 1 54 store double %b, ptr %add.ptr, align 8 55 ret double %tmp 56} 57 58; The next set of tests makes sure we can combine the first instruction into 59; the second. 60 61; CHECK-LABEL: stp_int_aa_after 62; CHECK: ldr w0, [x3, #4] 63; CHECK: stp w1, w2, [x3] 64; CHECK: ret 65define i32 @stp_int_aa_after(i32 %w0, i32 %a, i32 %b, ptr nocapture %p) nounwind { 66 store i32 %a, ptr %p, align 4 67 %ld.ptr = getelementptr inbounds i32, ptr %p, i64 1 68 %tmp = load i32, ptr %ld.ptr, align 4 69 %add.ptr = getelementptr inbounds i32, ptr %p, i64 1 70 store i32 %b, ptr %add.ptr, align 4 71 ret i32 %tmp 72} 73 74; CHECK-LABEL: stp_long_aa_after 75; CHECK: ldr x0, [x3, #8] 76; CHECK: stp x1, x2, [x3] 77; CHECK: ret 78define i64 @stp_long_aa_after(i64 %x0, i64 %a, i64 %b, ptr nocapture %p) nounwind { 79 store i64 %a, ptr %p, align 8 80 %ld.ptr = getelementptr inbounds i64, ptr %p, i64 1 81 %tmp = load i64, ptr %ld.ptr, align 4 82 %add.ptr = getelementptr inbounds i64, ptr %p, i64 1 83 store i64 %b, ptr %add.ptr, align 8 84 ret i64 %tmp 85} 86 87; CHECK-LABEL: stp_float_aa_after 88; CHECK: ldr s0, [x0, #4] 89; CHECK: stp s1, s2, [x0] 90; CHECK: ret 91define float @stp_float_aa_after(float %s0, float %a, float %b, ptr nocapture %p) nounwind { 92 store float %a, ptr %p, align 4 93 %ld.ptr = getelementptr inbounds float, ptr %p, i64 1 94 %tmp = load float, ptr %ld.ptr, align 4 95 %add.ptr = getelementptr inbounds float, ptr %p, i64 1 96 store float %b, ptr %add.ptr, align 4 97 ret float %tmp 98} 99 100; CHECK-LABEL: stp_double_aa_after 101; CHECK: ldr d0, [x0, #8] 102; CHECK: stp d1, d2, [x0] 103; CHECK: ret 104define double @stp_double_aa_after(double %d0, double %a, double %b, ptr nocapture %p) nounwind { 105 store double %a, ptr %p, align 8 106 %ld.ptr = getelementptr inbounds double, ptr %p, i64 1 107 %tmp = load double, ptr %ld.ptr, align 4 108 %add.ptr = getelementptr inbounds double, ptr %p, i64 1 109 store double %b, ptr %add.ptr, align 8 110 ret double %tmp 111} 112 113; Check that the stores %c and %d are paired after the fadd instruction, 114; and then the stores %a and %d are paired after proving that they do not 115; depend on the (%c, %d) pair. 116; 117; CHECK-LABEL: st1: 118; CHECK: stp q0, q1, [x{{[0-9]+}}] 119; CHECK: fadd 120; CHECK: stp q2, q0, [x{{[0-9]+}}, #32] 121define void @st1(<4 x float> %a, <4 x float> %b, <4 x float> %c, <4 x float> %d, ptr %base, i64 %index) { 122entry: 123 %a0 = getelementptr inbounds float, ptr %base, i64 %index 124 %b0 = getelementptr float, ptr %a0, i64 4 125 %c0 = getelementptr float, ptr %a0, i64 8 126 %d0 = getelementptr float, ptr %a0, i64 12 127 128 129 store <4 x float> %c, ptr %c0, align 4 130 store <4 x float> %a, ptr %a0, align 4 131 132 ; This fadd forces the compiler to pair %c and %e after fadd, and leave the 133 ; stores %a and %b separated by a stp. The dependence analysis needs then to 134 ; prove that it is safe to move %b past the stp to be paired with %a. 135 %e = fadd fast <4 x float> %d, %a 136 137 store <4 x float> %e, ptr %d0, align 4 138 store <4 x float> %b, ptr %b0, align 4 139 140 ret void 141} 142