1 ; RUN: opt < %s -passes=loop-vectorize,dce,instcombine -force-vector-interleave=1 -force-vector-width=4 -S | FileCheck %s
3 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
4 target triple = "x86_64-unknown-linux-gnu"
6 ; The parallel loop has been invalidated by the new memory accesses introduced
7 ; by reg2mem (Loop::isParallel() starts to return false). Ensure the loop is
8 ; now non-vectorizable.
11 define void @parallel_loop(ptr nocapture %a, ptr nocapture %b) nounwind uwtable {
13 %indvars.iv.next.reg2mem = alloca i64
14 %indvars.iv.reg2mem = alloca i64
15 %"reg2mem alloca point" = bitcast i32 0 to i32
16 store i64 0, ptr %indvars.iv.reg2mem
19 for.body: ; preds = %for.body.for.body_crit_edge, %entry
20 %indvars.iv.reload = load i64, ptr %indvars.iv.reg2mem
21 %arrayidx = getelementptr inbounds i32, ptr %b, i64 %indvars.iv.reload
22 %0 = load i32, ptr %arrayidx, align 4, !llvm.access.group !4
23 %arrayidx2 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.reload
24 %1 = load i32, ptr %arrayidx2, align 4, !llvm.access.group !4
25 %idxprom3 = sext i32 %1 to i64
26 %arrayidx4 = getelementptr inbounds i32, ptr %a, i64 %idxprom3
27 store i32 %0, ptr %arrayidx4, align 4, !llvm.access.group !4
28 %indvars.iv.next = add i64 %indvars.iv.reload, 1
29 ; A new store without the parallel metadata here:
30 store i64 %indvars.iv.next, ptr %indvars.iv.next.reg2mem
31 %indvars.iv.next.reload1 = load i64, ptr %indvars.iv.next.reg2mem
32 %arrayidx6 = getelementptr inbounds i32, ptr %b, i64 %indvars.iv.next.reload1
33 %2 = load i32, ptr %arrayidx6, align 4, !llvm.access.group !4
34 store i32 %2, ptr %arrayidx2, align 4, !llvm.access.group !4
35 %indvars.iv.next.reload = load i64, ptr %indvars.iv.next.reg2mem
36 %lftr.wideiv = trunc i64 %indvars.iv.next.reload to i32
37 %exitcond = icmp eq i32 %lftr.wideiv, 512
38 br i1 %exitcond, label %for.end, label %for.body.for.body_crit_edge, !llvm.loop !3
40 for.body.for.body_crit_edge: ; preds = %for.body
41 %indvars.iv.next.reload2 = load i64, ptr %indvars.iv.next.reg2mem
42 store i64 %indvars.iv.next.reload2, ptr %indvars.iv.reg2mem
45 for.end: ; preds = %for.body
49 !3 = !{!3, !{!"llvm.loop.parallel_accesses", !4}}