Add more tests from bugzilla
ADD
tests/alive-tv/bugs/pr1107.srctgt.ll
+; https://bugs.llvm.org/show_bug.cgi?id=1107
+
+define i1 @src(i8 %A, i8 %B) {
+ %a = zext i8 %A to i32 ; <i32> [#uses=1]
+ %b = zext i8 %B to i32 ; <i32> [#uses=1]
+ %c = icmp sgt i32 %a, %b ; <bool> [#uses=1]
+ ret i1 %c
+}
+
+define i1 @tgt(i8 %A, i8 %B) {
+ %c = icmp sgt i8 %A, %B ; <bool> [#uses=1]
+ ret i1 %c
+}
+
+; ERROR: Value mismatch

ADD
tests/alive-tv/bugs/pr23675.srctgt.ll
+; https://bugs.llvm.org/show_bug.cgi?id=23675
+
+define i4 @src(i2, i1, i4, i2, i1, i4, i2, i1, i4, i2, i1, i4) {
+ %13 = mul nsw i4 -2, %2
+ %14 = add i4 %13, 3
+ ret i4 %14
+}
+
+define i4 @tgt(i2, i1, i4, i2, i1, i4, i2, i1, i4, i2, i1, i4) {
+ %13 = mul nsw i4 %2, 2
+ %14 = sub i4 3, %13
+ ret i4 %14
+}
+
+; ERROR: Target is more poisonous than source

ADD
tests/alive-tv/bugs/pr23757.srctgt.ll
+; https://bugs.llvm.org/show_bug.cgi?id=23757
+
+define zeroext i1 @src(i32* %cell_ptr) {
+ %1 = load i32, i32* %cell_ptr, align 4
+ %2 = icmp eq i32 %1, 2147483647
+ %3 = add nsw i32 %1, 1
+ %inc.0 = select i1 %2, i32 -2147483648, i32 %3
+ store i32 %inc.0, i32* %cell_ptr, align 4
+ %4 = icmp sgt i32 %inc.0, %1
+ ret i1 %4
+}
+
+define zeroext i1 @tgt(i32* %cell_ptr) {
+ %1 = load i32, i32* %cell_ptr, align 4
+ %2 = add nsw i32 %1, 1
+ store i32 %2, i32* %cell_ptr, align 4
+ ret i1 true
+}
+
+; ERROR: Value mismatch

ADD
tests/alive-tv/bugs/pr24248.srctgt.ll
+; https://bugs.llvm.org/show_bug.cgi?id=24248 , with minor modification (to make %pos visible)
+
+define void @src(i32 %x) {
+entry:
+ %vecinit = insertelement <2 x i32> <i32 0, i32 0>, i32 %x, i32 1
+ %inc = add i32 %x, 1
+ %0 = insertelement <2 x i32> %vecinit, i32 %inc, i32 1
+ br label %loop
+
+loop: ; preds = %loop, %entry
+ %pos = phi <2 x i32> [ %0, %entry ], [ %new.pos.y, %loop ]
+ %i = phi i32 [ 0, %entry ], [ %new.i, %loop ]
+ call void @f(<2 x i32> %pos)
+ %pos.y = extractelement <2 x i32> %pos, i32 1
+ %inc.pos.y = add i32 %pos.y, 1
+ %new.pos.y = insertelement <2 x i32> %pos, i32 %inc.pos.y, i32 1
+ %new.i = add i32 %i, 1
+ %cmp2 = icmp slt i32 %new.i, 1
+ br i1 %cmp2, label %loop, label %exit
+
+exit: ; preds = %loop
+ ret void
+}
+
+define void @tgt(i32 %x) {
+entry:
+ %vecinit = insertelement <2 x i32> zeroinitializer, i32 %x, i32 1
+ %inc = add i32 %x, 1
+ %0 = insertelement <2 x i32> %vecinit, i32 %inc, i32 1
+ br label %loop
+
+loop: ; preds = %loop, %entry
+ %pos.i0 = phi i32 [ 0, %entry ], [ %pos.i01, %loop ]
+ %pos.i1 = phi i32 [ %x, %entry ], [ %inc.pos.y, %loop ]
+ %i = phi i32 [ 0, %entry ], [ %new.i, %loop ]
+ %pos.upto0 = insertelement <2 x i32> undef, i32 %pos.i0, i32 0
+ %pos = insertelement <2 x i32> %pos.upto0, i32 %pos.i1, i32 1
+ call void @f(<2 x i32> %pos)
+ %pos.y = extractelement <2 x i32> %pos, i32 1
+ %inc.pos.y = add i32 %pos.y, 1
+ %new.pos.y = insertelement <2 x i32> %pos, i32 %inc.pos.y, i32 1
+ %pos.i01 = extractelement <2 x i32> %pos, i32 0
+ %new.i = add i32 %i, 1
+ %cmp2 = icmp slt i32 %new.i, 1
+ br i1 %cmp2, label %loop, label %exit
+
+exit: ; preds = %loop
+ ret void
+}
+
+declare void @f(<2 x i32>)
+
+; ERROR: Source is more defined than target

ADD
tests/alive-tv/bugs/pr24873.srctgt.ll
+; https://bugs.llvm.org/show_bug.cgi?id=24873
+
+define i1 @src(i64 %V) {
+ %ashr = ashr i64 -4611686018427387904, %V
+ %icmp = icmp eq i64 %ashr, -1
+ ret i1 %icmp
+}
+
+define i1 @tgt(i64 %V) {
+ %icmp = icmp eq i64 %V, 62
+ ret i1 %icmp
+}
+
+; ERROR: Value mismatch

ADD
tests/alive-tv/bugs/pr27575.srctgt.ll
+; https://bugs.llvm.org/show_bug.cgi?id=27575
+source_filename = "27575.src.ll"
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define double @src(i32 %shr) {
+entry:
+ %cmp = icmp sgt i32 %shr, 0
+ %conv = sitofp i32 %shr to double
+ %cond = select i1 %cmp, double %conv, double 5.000000e-01
+ ret double %cond
+}
+
+define double @tgt(i32 %shr) {
+entry:
+ %0 = icmp sgt i32 %shr, 0
+ %1 = select i1 %0, i32 %shr, i32 0
+ %2 = sitofp i32 %1 to double
+ ret double %2
+}
+
+; ERROR: Value mismatch

ADD
tests/alive-tv/bugs/pr32872.srctgt.ll
+ ; https://bugs.llvm.org/show_bug.cgi?id=32872
+
+ define <2 x float> @src(<2 x float> %v) {
+ %tmp1 = shufflevector <2 x float> %v, <2 x float> zeroinitializer, <4 x i32> <i32 2, i32 2, i32 0, i32 1>
+ %tmp4 = shufflevector <4 x float> zeroinitializer, <4 x float> %tmp1, <2 x i32> <i32 4, i32 5>
+ ret <2 x float> %tmp4
+ }
+
+define <2 x float> @tgt(<2 x float> %v) {
+ ret <2 x float> %v
+}
+
+; ERROR: Target is more poisonous than source

ADD
tests/alive-tv/bugs/pr32949.srctgt.ll
+; https://bugs.llvm.org/show_bug.cgi?id=32949
+
+define i1 @src(i8 %x) {
+ %div1 = sdiv exact i8 1, %x
+ %div2 = sdiv exact i8 -1, %x
+ %icmp = icmp ult i8 %div1, %div2
+ ret i1 %icmp
+}
+
+define i1 @tgt(i8 %x) {
+ ret i1 true
+}
+
+; ERROR: Value mismatch

ADD
tests/alive-tv/bugs/pr33673.srctgt.ll
+; https://bugs.llvm.org/show_bug.cgi?id=33673
+; To find counter-example from this, function should be able to throw or exit
+define void @src() {
+ %p = alloca i32, align 4
+ %a = load i32, i32* %p, align 4
+ call void @foo(i32 %a)
+ store i32 sdiv (i32 1, i32 sub (i32 ptrtoint (i32* @G to i32), i32 ptrtoint (i32* @G to i32))), i32* %p, align 4
+ ret void
+}
+
+@G = external global i32, align 4
+
+define void @tgt() {
+ call void @foo(i32 sdiv (i32 1, i32 sub (i32 ptrtoint (i32* @G to i32), i32 ptrtoint (i32* @G to i32))))
+ ret void
+}
+
+declare void @foo(i32)
+
+; XFAIL

ADD
tests/alive-tv/bugs/pr35406.srctgt.ll
+; https://bugs.llvm.org/show_bug.cgi?id=35406
+; Currently Alive2 simply rejects this example. After loop support, this should
+; be verified (as an incorrect transformation)
+
+; ModuleID = 'repro.ll'
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128:1"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @src(i8* %p, i64* %p1) {
+entry:
+ br label %loop1
+
+loop1:
+ %local_0_ = phi i32 [ 8, %entry ], [ %9, %loop2.exit ]
+ %local_2_ = phi i32 [ 63864, %entry ], [ %local_2_43, %loop2.exit ]
+ %local_3_ = phi i32 [ 51, %entry ], [ %local_3_44, %loop2.exit ]
+ %0 = udiv i32 14, %local_0_
+ %1 = icmp ugt i32 %local_0_, 14
+ br i1 %1, label %exit, label %general_case24
+
+general_case24:
+ %2 = udiv i32 60392, %0
+ br i1 false, label %loop2, label %loop2.exit
+
+loop2:
+ %local_1_56 = phi i32 [ %2, %general_case24 ], [ %3, %loop2 ]
+ %local_2_57 = phi i32 [ 1, %general_case24 ], [ %7, %loop2 ]
+ %3 = add i32 %local_1_56, -1
+ %4 = load i64, i64* %p1, align 8
+ %5 = sext i32 %3 to i64
+ %6 = sub i64 %4, %5
+ store i64 %6, i64* %p1, align 8
+ %7 = add nuw nsw i32 %local_2_57, 1
+ %8 = icmp ugt i32 %local_2_57, 7
+ br i1 %8, label %loop2.exit, label %loop2
+
+loop2.exit:
+ %local_2_43 = phi i32 [ %local_2_, %general_case24 ], [ 9, %loop2 ]
+ %local_3_44 = phi i32 [ %local_3_, %general_case24 ], [ %local_1_56, %loop2 ]
+ %9 = add nuw nsw i32 %local_0_, 1
+ %10 = icmp ugt i32 %local_0_, 129
+ br i1 %10, label %exit, label %loop1
+
+exit:
+ ret i32 0
+}
+
+define i32 @tgt(i8* %p, i64* %p1) {
+entry:
+ br label %loop1
+
+loop1: ; preds = %loop2.exit, %entry
+ %local_0_ = phi i32 [ 8, %entry ], [ %7, %loop2.exit ]
+ %0 = udiv i32 14, %local_0_
+ %1 = udiv i32 60392, %0
+ %2 = zext i32 %1 to i64
+ %3 = icmp ugt i32 %local_0_, 14
+ br i1 %3, label %exit, label %general_case24
+
+general_case24: ; preds = %loop1
+ br i1 false, label %loop2.preheader, label %loop2.exit
+
+loop2.preheader: ; preds = %general_case24
+ br label %loop2
+
+loop2: ; preds = %loop2.preheader, %loop2
+ %indvars.iv = phi i64 [ %2, %loop2.preheader ], [ %indvars.iv.next, %loop2 ]
+ %local_2_57 = phi i32 [ %6, %loop2 ], [ 1, %loop2.preheader ]
+ %indvars.iv.next = add nsw i64 %indvars.iv, -1
+ %4 = load i64, i64* %p1, align 8
+ %5 = sub i64 %4, %indvars.iv.next
+ store i64 %5, i64* %p1, align 8
+ %6 = add nuw nsw i32 %local_2_57, 1
+ %exitcond = icmp eq i32 %6, 9
+ br i1 %exitcond, label %loop2.exit.loopexit, label %loop2
+
+loop2.exit.loopexit: ; preds = %loop2
+ br label %loop2.exit
+
+loop2.exit: ; preds = %loop2.exit.loopexit, %general_case24
+ %7 = add nuw nsw i32 %local_0_, 1
+ br i1 false, label %exit, label %loop1
+
+exit: ; preds = %loop2.exit, %loop1
+ ret i32 0
+}
+
+; XFAIL: Precondition is always false

ADD
tests/alive-tv/bugs/pr36133.srctgt.ll
+; https://bugs.llvm.org/show_bug.cgi?id=36133
+@global = external local_unnamed_addr global i8*, align 8
+
+define i32 @src(i32 %arg) local_unnamed_addr #0 {
+bb:
+ %tmp = load i8*, i8** @global, align 8
+ %tmp1 = icmp eq i8* %tmp, null
+ br i1 %tmp1, label %bb3, label %bb2
+
+bb2:
+ br label %bb3
+
+bb3:
+ %tmp4 = phi i8 [ 1, %bb2 ], [ 0, %bb ]
+ %tmp5 = icmp eq i8 %tmp4, 0
+ br i1 %tmp5, label %bb7, label %bb6
+
+bb6:
+ br label %bb7
+
+bb7:
+ %tmp8 = icmp eq i32 %arg, -1
+ br i1 %tmp8, label %bb9, label %bb10 ; Does not depend on the content of @global, only %arg
+
+bb9: ; Single pred - %bb7
+ ret i32 0
+
+bb10: ; Single pred - %bb7
+ %tmp11 = icmp sgt i32 %arg, -1
+ call void @llvm.assume(i1 %tmp11)
+ ret i32 1
+}
+
+; Function Attrs: nounwind
+declare void @llvm.assume(i1) #1
+
+attributes #0 = { uwtable }
+attributes #1 = { nounwind }
+
+; Function Attrs: uwtable
+define i32 @tgt(i32 %arg) local_unnamed_addr #0 {
+bb:
+ %tmp = load i8*, i8** @global, align 8
+ %tmp1 = icmp eq i8* %tmp, null
+ br i1 %tmp1, label %bb10, label %bb7 ; This now bypasses %arg check directly going to one of the possible rets
+
+bb7:
+ %tmp8 = icmp eq i32 %arg, -1
+ br i1 %tmp8, label %bb9, label %bb10
+
+bb9:
+ ret i32 0
+
+bb10:
+ %tmp11 = icmp sgt i32 %arg, -1
+ call void @llvm.assume(i1 %tmp11)
+ ret i32 1
+}
+
+; ERROR: Source is more defined than target

ADD
tests/alive-tv/bugs/pr36437.srctgt.ll
+; https://bugs.llvm.org/show_bug.cgi?id=36437
+; Currently Alive2 simply rejects this example. After loop support, this should
+; be verified (as an incorrect transformation)
+
+define i32 @src() local_unnamed_addr {
+entry:
+ store i32 3, i32* @a, align 4
+ br label %for.body
+
+for.body: ; preds = %entry, %for.body
+ %d.05 = phi i32 [ 0, %entry ], [ -1, %for.body ]
+ %0 = load i32*, i32** @c, align 8
+ %1 = load i32, i32* %0, align 4
+ %and = and i32 %1, %d.05
+ store i32 %and, i32* %0, align 4
+ %2 = load i32, i32* @a, align 4
+ %sext = shl i32 %2, 16
+ %conv3 = ashr exact i32 %sext, 16
+ %sub = add nsw i32 %conv3, -1
+ store i32 %sub, i32* @a, align 4
+ %cmp = icmp eq i32 %sub, 5
+ br i1 %cmp, label %for.end, label %for.body
+
+for.end: ; preds = %for.body
+ %3 = load i32, i32* @b, align 4
+ %call = tail call i32 (i8*, ...) @print(i8* nonnull dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %3)
+ ret i32 0
+}
+
+define i32 @tgt() local_unnamed_addr {
+entry:
+ store i32 3, i32* @a, align 4
+ br label %for.body
+
+for.body: ; preds = %entry, %for.body
+ %phiofops = phi i32 [ 0, %entry ], [ %1, %for.body ]
+ %d.05 = phi i32 [ 0, %entry ], [ -1, %for.body ]
+ %0 = load i32*, i32** @c, align 8
+ %1 = load i32, i32* %0, align 4
+ store i32 %phiofops, i32* %0, align 4
+ %2 = load i32, i32* @a, align 4
+ %sext = shl i32 %2, 16
+ %conv3 = ashr exact i32 %sext, 16
+ %sub = add nsw i32 %conv3, -1
+ store i32 %sub, i32* @a, align 4
+ %cmp = icmp eq i32 %sub, 5
+ br i1 %cmp, label %for.end, label %for.body
+
+for.end: ; preds = %for.body
+ %3 = load i32, i32* @b, align 4
+ %call = tail call i32 (i8*, ...) @print(i8* nonnull dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %3)
+ ret i32 0
+}
+
+; XFAIL: Precondition is always false
+
+@b = global i32 2, align 4
+@c = global i32* @b, align 8
+@a = common global i32 0, align 4
+@.str = private unnamed_addr constant [15 x i8] c"checksum = %X\0A\00", align 1
+declare i32 @print(i8*, ...)

ADD
tests/alive-tv/bugs/pr39510.srctgt.ll
+; https://bugs.llvm.org/show_bug.cgi?id=39510
+
+define i1 @src(i32 %a) {
+ %cmp = icmp slt i32 %a, 0
+ %sub = sub nsw i32 0, %a
+ %cond = select i1 %cmp, i32 %sub, i32 %a
+ %r = icmp ne i32 %cond, 2
+ ret i1 %r
+}
+
+define i1 @tgt(i32 %a) {
+ ret i1 1
+}
+
+; ERROR: Value mismatch

Add more tests from bugzilla (#319)