add LLVM regression tests
ADD
tests/alive-tv/bugs/pr48125.srctgt.ll
+; TEST-ARGS: -src-unroll=8 -tgt-unroll=8
+; ERROR: Source is more defined than target
+
+; https://bugs.llvm.org/show_bug.cgi?id=48125
+
+@a = external global [8 x i32], align 16
+
+define void @src() {
+entry:
+ br label %for.body
+
+for.body: ; preds = %for.body, %entry
+ %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
+ %arrayidx = getelementptr inbounds [8 x i32], [8 x i32]* @a, i64 0, i64 %indvars.iv
+ store i32 undef, i32* %arrayidx, align 4
+ %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
+ %exitcond = icmp ne i64 %indvars.iv.next, 8
+ br i1 %exitcond, label %for.body, label %for.exit
+
+for.exit: ; preds = %for.body
+ ret void
+}
+
+define void @tgt() {
+entry:
+ br label %for.body.peel.begin
+
+for.body.peel.begin: ; preds = %entry
+ br label %for.body.peel
+
+for.body.peel: ; preds = %for.body.peel.begin
+ %arrayidx.peel = getelementptr inbounds [8 x i32], [8 x i32]* @a, i64 0, i64 0
+ store i32 undef, i32* %arrayidx.peel, align 4
+ %indvars.iv.next.peel = add nuw nsw i64 0, 1
+ %exitcond.peel = icmp ne i64 %indvars.iv.next.peel, 8
+ br i1 %exitcond.peel, label %for.body.peel.next, label %for.exit
+
+for.body.peel.next: ; preds = %for.body.peel
+ br label %for.body.peel2
+
+for.body.peel2: ; preds = %for.body.peel.next
+ %arrayidx.peel3 = getelementptr inbounds [8 x i32], [8 x i32]* @a, i64 0, i64 %indvars.iv.next.peel
+ store i32 undef, i32* %arrayidx.peel3, align 4
+ %indvars.iv.next.peel4 = add nuw nsw i64 %indvars.iv.next.peel, 1
+ %exitcond.peel5 = icmp ne i64 %indvars.iv.next.peel4, 8
+ br i1 %exitcond.peel5, label %for.body.peel.next1, label %for.exit
+
+for.body.peel.next1: ; preds = %for.body.peel2
+ br label %for.body.peel.next6
+
+for.body.peel.next6: ; preds = %for.body.peel.next1
+ br label %entry.peel.newph
+
+entry.peel.newph: ; preds = %for.body.peel.next6
+ br label %for.body
+
+for.body: ; preds = %entry.peel.newph
+ %arrayidx = getelementptr inbounds [8 x i32], [8 x i32]* @a, i64 0, i64 %indvars.iv.next.peel4
+ store i32 undef, i32* %arrayidx, align 4
+ store i32 undef, i32* getelementptr inbounds ([8 x i32], [8 x i32]* @a, i64 0, i64 3), align 4
+ store i32 undef, i32* getelementptr inbounds ([8 x i32], [8 x i32]* @a, i64 0, i64 4), align 4
+ store i32 undef, i32* getelementptr inbounds ([8 x i32], [8 x i32]* @a, i64 0, i64 5), align 4
+ store i32 undef, i32* getelementptr inbounds ([8 x i32], [8 x i32]* @a, i64 0, i64 6), align 4
+ store i32 undef, i32* getelementptr inbounds ([8 x i32], [8 x i32]* @a, i64 0, i64 7), align 4
+ store i32 undef, i32* getelementptr inbounds ([8 x i32], [8 x i32]* @a, i64 1, i64 0), align 4
+ store i32 undef, i32* getelementptr ([8 x i32], [8 x i32]* @a, i64 1, i64 1), align 4
+ br label %for.exit
+
+for.exit: ; preds = %for.body, %for.body.peel2, %for.body.peel
+ ret void
+}

ADD
tests/alive-tv/bugs/pr48126.srctgt.ll
+; TEST-ARGS: -src-unroll=4 -tgt-unroll=4
+; ERROR: Source is more defined than target
+
+; https://bugs.llvm.org/show_bug.cgi?id=48126
+
+@b = external global [2048 x i32], align 16
+
+define i32 @src(i32* %b, i32 %n) #0 {
+ %1 = icmp sgt i32 %n, 0
+ br i1 %1, label %.lr.ph, label %._crit_edge
+
+.lr.ph: ; preds = %0
+ %2 = sext i32 %n to i64
+ br label %3
+
+3: ; preds = %3, %.lr.ph
+ %indvars.iv = phi i64 [ %2, %.lr.ph ], [ %indvars.iv.next, %3 ]
+ %indvars.iv.next = add i64 %indvars.iv, -1
+ %4 = getelementptr inbounds i32, i32* %b, i64 %indvars.iv.next
+ %5 = load i32, i32* %4, align 4
+ %6 = add nsw i32 %5, 0
+ %7 = trunc i64 %indvars.iv.next to i32
+ %8 = icmp sgt i32 %7, 0
+ br i1 %8, label %3, label %._crit_edge
+
+._crit_edge: ; preds = %3, %0
+ %a.0.lcssa = phi i32 [ 0, %0 ], [ %6, %3 ]
+ ret i32 %a.0.lcssa
+}
+
+
+define i32 @tgt(i32* %b, i32 %n) #0 {
+ %1 = icmp sgt i32 %n, 0
+ br i1 %1, label %.lr.ph, label %._crit_edge
+
+.lr.ph: ; preds = %0
+ %2 = sext i32 %n to i64
+ %3 = add i32 %n, -1
+ %4 = zext i32 %3 to i64
+ %5 = add nuw nsw i64 %4, 1
+ %min.iters.check = icmp ult i32 %3, 3
+ br i1 %min.iters.check, label %scalar.ph, label %vector.ph
+
+vector.ph: ; preds = %.lr.ph
+ %n.vec = and i64 %5, 8589934588
+ %ind.end = sub nsw i64 %2, %n.vec
+ br label %vector.body
+
+vector.body: ; preds = %vector.body, %vector.ph
+ %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
+ %index.next = add i64 %index, 4
+ %6 = icmp eq i64 %index.next, %n.vec
+ br i1 %6, label %middle.block, label %vector.body
+
+middle.block: ; preds = %vector.body
+ %7 = getelementptr inbounds i32, i32* %b, i64 -3
+ %8 = xor i64 %index, -1
+ %9 = add i64 %8, %2
+ %10 = getelementptr inbounds i32, i32* %7, i64 %9
+ %11 = bitcast i32* %10 to <4 x i32>*
+ %wide.load = load <4 x i32>, <4 x i32>* %11, align 4
+ %cmp.n = icmp eq i64 %5, %n.vec
+ %12 = extractelement <4 x i32> %wide.load, i32 0
+ br i1 %cmp.n, label %._crit_edge.loopexit, label %scalar.ph
+
+scalar.ph: ; preds = %middle.block, %.lr.ph
+ %bc.resume.val = phi i64 [ %ind.end, %middle.block ], [ %2, %.lr.ph ]
+ br label %13
+
+13: ; preds = %13, %scalar.ph
+ %indvars.iv = phi i64 [ %bc.resume.val, %scalar.ph ], [ %indvars.iv.next, %13 ]
+ %indvars.iv.next = add i64 %indvars.iv, -1
+ %14 = getelementptr inbounds i32, i32* %b, i64 %indvars.iv.next
+ %15 = load i32, i32* %14, align 4
+ %16 = trunc i64 %indvars.iv.next to i32
+ %17 = icmp sgt i32 %16, 0
+ br i1 %17, label %13, label %._crit_edge.loopexit
+
+._crit_edge.loopexit: ; preds = %middle.block, %13
+ %.lcssa = phi i32 [ %15, %13 ], [ %12, %middle.block ]
+ br label %._crit_edge
+
+._crit_edge: ; preds = %._crit_edge.loopexit, %0
+ %a.0.lcssa = phi i32 [ 0, %0 ], [ %.lcssa, %._crit_edge.loopexit ]
+ ret i32 %a.0.lcssa
+}
+

ADD
tests/alive-tv/bugs/pr48127.srctgt.ll
+; TEST-ARGS: -src-unroll=4 -tgt-unroll=4
+; ERROR: Source is more defined than target
+
+; https://bugs.llvm.org/show_bug.cgi?id=48127
+
+define void @src(i32* %a, i32 %x, i32 %y, i32 %z, i64 %n) {
+entry:
+ br label %for.body
+
+for.body: ; preds = %for.body, %entry
+ %i = phi i64 [ %i.next, %for.body ], [ 0, %entry ]
+ %i_plus_1 = add i64 %i, 1
+ %a_i = getelementptr inbounds i32, i32* %a, i64 %i
+ %a_i_plus_1 = getelementptr inbounds i32, i32* %a, i64 %i_plus_1
+ store i32 %x, i32* %a_i, align 4
+ store i32 %y, i32* %a_i, align 4
+ store i32 %z, i32* %a_i_plus_1, align 4
+ %i.next = add nuw nsw i64 %i, 2
+ %cond = icmp slt i64 %i.next, %n
+ br i1 %cond, label %for.body, label %for.end
+
+for.end: ; preds = %for.body
+ ret void
+}
+
+
+define void @tgt(i32* %a, i32 %x, i32 %y, i32 %z, i64 %n) {
+entry:
+ %0 = icmp sgt i64 %n, 2
+ %smax = select i1 %0, i64 %n, i64 2
+ %1 = add nsw i64 %smax, -1
+ %2 = lshr i64 %1, 1
+ %3 = add nuw nsw i64 %2, 1
+ %min.iters.check = icmp ult i64 %1, 6
+ br i1 %min.iters.check, label %scalar.ph, label %vector.ph
+
+vector.ph: ; preds = %entry
+ %n.vec = and i64 %3, 9223372036854775804
+ %ind.end = shl nuw i64 %n.vec, 1
+ %broadcast.splatinsert = insertelement <4 x i32> undef, i32 %y, i32 0
+ %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> undef, <4 x i32> zeroinitializer
+ %broadcast.splatinsert1 = insertelement <4 x i32> undef, i32 %z, i32 0
+ %broadcast.splat2 = shufflevector <4 x i32> %broadcast.splatinsert1, <4 x i32> undef, <4 x i32> zeroinitializer
+ br label %vector.body
+
+vector.body: ; preds = %vector.body, %vector.ph
+ %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
+ %offset.idx = shl i64 %index, 1
+ %4 = or i64 %offset.idx, 2
+ %5 = or i64 %offset.idx, 4
+ %6 = or i64 %offset.idx, 6
+ %7 = or i64 %offset.idx, 1
+ %8 = getelementptr inbounds i32, i32* %a, i64 %offset.idx
+ %9 = getelementptr inbounds i32, i32* %a, i64 %4
+ %10 = getelementptr inbounds i32, i32* %a, i64 %5
+ %11 = getelementptr inbounds i32, i32* %a, i64 %6
+ %12 = getelementptr inbounds i32, i32* %a, i64 -1
+ store i32 %x, i32* %8, align 4
+ store i32 %x, i32* %9, align 4
+ store i32 %x, i32* %10, align 4
+ store i32 %x, i32* %11, align 4
+ %13 = getelementptr inbounds i32, i32* %12, i64 %7
+ %14 = bitcast i32* %13 to <8 x i32>*
+ %interleaved.vec = shufflevector <4 x i32> %broadcast.splat, <4 x i32> %broadcast.splat2, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>
+ store <8 x i32> %interleaved.vec, <8 x i32>* %14, align 4
+ %index.next = add i64 %index, 4
+ %15 = icmp eq i64 %index.next, %n.vec
+ br i1 %15, label %middle.block, label %vector.body
+
+middle.block: ; preds = %vector.body
+ %cmp.n = icmp eq i64 %3, %n.vec
+ br i1 %cmp.n, label %for.end, label %scalar.ph
+
+scalar.ph: ; preds = %middle.block, %entry
+ %bc.resume.val = phi i64 [ %ind.end, %middle.block ], [ 0, %entry ]
+ br label %for.body
+
+for.body: ; preds = %for.body, %scalar.ph
+ %i = phi i64 [ %i.next, %for.body ], [ %bc.resume.val, %scalar.ph ]
+ %i_plus_1 = or i64 %i, 1
+ %a_i = getelementptr inbounds i32, i32* %a, i64 %i
+ %a_i_plus_1 = getelementptr inbounds i32, i32* %a, i64 %i_plus_1
+ store i32 %y, i32* %a_i, align 4
+ store i32 %z, i32* %a_i_plus_1, align 4
+ %i.next = add nuw nsw i64 %i, 2
+ %cond = icmp slt i64 %i.next, %n
+ br i1 %cond, label %for.body, label %for.end
+
+for.end: ; preds = %middle.block, %for.body
+ ret void
+}
+

add LLVM regression tests (#576)