brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · 111aafc Raw
79 lines · plain
1; RUN: opt -passes=loop-vectorize -force-vector-width=2 \2; RUN:     -force-vector-interleave=1 -S < %s \3; RUN:     | FileCheck %s -check-prefix=BOTH -check-prefix=LV4; RUN: opt -passes=loop-vectorize,dse -force-vector-width=2 \5; RUN:     -force-vector-interleave=1 -S < %s \6; RUN:     | FileCheck %s -check-prefix=BOTH -check-prefix=DSE7 8target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"9 10; This loop needs to be versioned with memchecks between {A, B} x {C} before11; it can be vectorized.12;13;   for (i = 0; i < n; i++) {14;     C[i] = A[i] + 1;15;     C[i] += B[i];16;   }17;18; Check that the corresponding noalias metadata is added to the vector loop19; but not to the scalar loop.20;21; Since in the versioned vector loop C and B can no longer alias, the first22; store to C[i] can be DSE'd.23 24 25define void @f(ptr %a, ptr %b, ptr %c) {26entry:27  br label %for.body28 29; BOTH: vector.memcheck:30; BOTH: vector.body:31for.body:                                         ; preds = %for.body, %entry32  %ind = phi i64 [ 0, %entry ], [ %inc, %for.body ]33 34  %arrayidxA = getelementptr inbounds i32, ptr %a, i64 %ind35; Scope 136; LV: = load {{.*}} !alias.scope !037  %loadA = load i32, ptr %arrayidxA, align 438 39  %add = add nuw i32 %loadA, 240 41  %arrayidxC = getelementptr inbounds i32, ptr %c, i64 %ind42; Noalias with scope 1 and 643; LV: store {{.*}} !alias.scope !3, !noalias !544; DSE-NOT: store45  store i32 %add, ptr %arrayidxC, align 446 47  %arrayidxB = getelementptr inbounds i32, ptr %b, i64 %ind48; Scope 649; LV: = load {{.*}} !alias.scope !750  %loadB = load i32, ptr %arrayidxB, align 451 52  %add2 = add nuw i32 %add, %loadB53 54; Noalias with scope 1 and 655; LV: store {{.*}} !alias.scope !3, !noalias !556; DSE: store57  store i32 %add2, ptr %arrayidxC, align 458 59  %inc = add nuw nsw i64 %ind, 160  %exitcond = icmp eq i64 %inc, 2061  br i1 %exitcond, label %for.end, label %for.body62 63; BOTH: for.body:64; BOTH-NOT: !alias.scope65; BOTH-NOT: !noalias66 67for.end:                                          ; preds = %for.body68  ret void69}70 71; LV: !0 = !{!1}72; LV: !1 = distinct !{!1, !2}73; LV: !2 = distinct !{!2, !"LVerDomain"}74; LV: !3 = !{!4}75; LV: !4 = distinct !{!4, !2}76; LV: !5 = !{!1, !6}77; LV: !6 = distinct !{!6, !2}78; LV: !7 = !{!6}79