57 lines · plain
1; RUN: opt < %s -force-vector-interleave=1 -store-to-load-forwarding-conflict-detection=false -passes=loop-vectorize,dce,instcombine -S | FileCheck %s2 3target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"4target triple = "aarch64--linux-gnu"5 6%struct.pair = type { i32, i32 }7 8; Check vectorization of interleaved access groups with positive dependence9; distances. In this test, the maximum safe dependence distance for10; vectorization is 16 bytes. Normally, this would lead to a maximum VF of 4.11; However, for interleaved groups, the effective VF is VF * IF, where IF is the12; interleave factor. Here, the maximum safe dependence distance is recomputed13; as 16 / IF bytes, resulting in VF=2. Since IF=2, we should generate <4 x i32>14; loads and stores instead of <8 x i32> accesses.15;16; Note: LAA's conflict detection optimization has to be disabled for this test17; to be vectorized.18 19; struct pair {20; int x;21; int y;22; };23;24; void max_vf(struct pair *restrict p) {25; for (int i = 0; i < 1000; i++) {26; p[i + 2].x = p[i].x27; p[i + 2].y = p[i].y28; }29; }30 31; CHECK-LABEL: @max_vf32; CHECK: load <4 x i32>33; CHECK: store <4 x i32>34 35define void @max_vf(ptr noalias nocapture %p) {36entry:37 br label %for.body38 39for.body:40 %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]41 %0 = add nuw nsw i64 %i, 242 %p_i.x = getelementptr inbounds %struct.pair, ptr %p, i64 %i, i32 043 %p_i_plus_2.x = getelementptr inbounds %struct.pair, ptr %p, i64 %0, i32 044 %1 = load i32, ptr %p_i.x, align 445 store i32 %1, ptr %p_i_plus_2.x, align 446 %p_i.y = getelementptr inbounds %struct.pair, ptr %p, i64 %i, i32 147 %p_i_plus_2.y = getelementptr inbounds %struct.pair, ptr %p, i64 %0, i32 148 %2 = load i32, ptr %p_i.y, align 449 store i32 %2, ptr %p_i_plus_2.y, align 450 %i.next = add nuw nsw i64 %i, 151 %cond = icmp eq i64 %i.next, 100052 br i1 %cond, label %for.exit, label %for.body53 54for.exit:55 ret void56}57