1; REQUIRES: asserts 2; RUN: opt -mtriple=s390x-unknown-linux -mcpu=z13 -passes=loop-vectorize \ 3; RUN: -force-vector-width=4 -debug-only=loop-vectorize,vectorutils \ 4; RUN: -disable-output < %s 2>&1 | FileCheck %s 5; 6; Check that the loop vectorizer performs memory interleaving with accurate 7; cost estimations. 8 9 10; Simple case where just the load is interleaved, because the store group 11; would have gaps. 12define void @fun0(ptr %data, i64 %n) { 13entry: 14 br label %for.body 15 16for.body: 17 %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ] 18 %tmp0 = getelementptr inbounds i32, ptr %data, i64 %i 19 %tmp1 = load i32, ptr %tmp0, align 4 20 %tmp2 = add i32 %tmp1, 1 21 store i32 %tmp2, ptr %tmp0, align 4 22 %i.next = add nuw nsw i64 %i, 2 23 %cond = icmp slt i64 %i.next, %n 24 br i1 %cond, label %for.body, label %for.end 25 26for.end: 27 ret void 28 29; CHECK: LV: Creating an interleave group with: %tmp1 = load i32, ptr %tmp0, align 4 30; CHECK: LV: Found an estimated cost of 3 for VF 4 For instruction: %tmp1 = load i32, ptr %tmp0, align 4 31; (vl; vl; vperm) 32} 33 34; Interleaving of both load and stores. 35define void @fun1(ptr %data, i64 %n) { 36entry: 37 br label %for.body 38 39for.body: 40 %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ] 41 %tmp0 = getelementptr inbounds i32, ptr %data, i64 %i 42 %tmp1 = load i32, ptr %tmp0, align 4 43 %i_1 = add i64 %i, 1 44 %tmp2 = getelementptr inbounds i32, ptr %data, i64 %i_1 45 %tmp3 = load i32, ptr %tmp2, align 4 46 store i32 %tmp1, ptr %tmp2, align 4 47 store i32 %tmp3, ptr %tmp0, align 4 48 %i.next = add nuw nsw i64 %i, 2 49 %cond = icmp slt i64 %i.next, %n 50 br i1 %cond, label %for.body, label %for.end 51 52for.end: 53 ret void 54 55; CHECK: LV: Creating an interleave group with: store i32 %tmp3, ptr %tmp0, align 4 56; CHECK: LV: Inserted: store i32 %tmp1, ptr %tmp2, align 4 57; CHECK: into the interleave group with store i32 %tmp3, ptr %tmp0, align 4 58; CHECK: LV: Creating an interleave group with: %tmp3 = load i32, ptr %tmp2, align 4 59; CHECK: LV: Inserted: %tmp1 = load i32, ptr %tmp0, align 4 60; CHECK: into the interleave group with %tmp3 = load i32, ptr %tmp2, align 4 61 62; CHECK: LV: Found an estimated cost of 4 for VF 4 For instruction: %tmp1 = load i32, ptr %tmp0, align 4 63; CHECK: LV: Found an estimated cost of 0 for VF 4 For instruction: %tmp3 = load i32, ptr %tmp2, align 4 64; (vl; vl; vperm, vpkg) 65 66; CHECK: LV: Found an estimated cost of 0 for VF 4 For instruction: store i32 %tmp1, ptr %tmp2, align 4 67; CHECK: LV: Found an estimated cost of 4 for VF 4 For instruction: store i32 %tmp3, ptr %tmp0, align 4 68; (vmrlf; vmrhf; vst; vst) 69} 70 71