Test Failure: Transforms/IndVarSimplify/widen-loop-comp.ll

Test source: git

Log:

Source: <stdin>
ERROR: Unsupported instruction:   invoke void @test14a-callee(i1 %loop.cond)
          to label %loop unwind label %exception
ERROR: Unsupported instruction:   %loaded = load atomic i32, i32* %addr unordered, align 4

----------------------------------------
@idx = global 4 bytes, align 4
@e = global 4 bytes, align 4
@ptr = global 8 bytes, align 8

define i32 @test1() {
%entry:
  store i32 4294967295, * @idx, align 4
  %0 = load i32, * @e, align 4
  %cmp4 = icmp slt i32 %0, 0
  br i1 %cmp4, label %for.end.loopexit, label %for.body.lr.ph

%for.body.lr.ph:
  %1 = load *, * @ptr, align 8
  %2 = load i32, * @e, align 4
  br label %for.body

%for.body:
  %i.05 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.cond ]
  %idxprom = sext i32 %i.05 to i64
  %arrayidx = gep inbounds * %1, 4 x i64 %idxprom
  %3 = load i32, * %arrayidx, align 4
  %tobool = icmp eq i32 %3, 0
  br i1 %tobool, label %if.then, label %for.cond

%if.then:
  %i.05.lcssa = phi i32 [ %i.05, %for.body ]
  store i32 %i.05.lcssa, * @idx, align 4
  br label %for.end

%for.cond:
  %inc = add nsw i32 %i.05, 1
  %cmp = icmp slt i32 %i.05, %2
  br i1 %cmp, label %for.body, label %for.cond.for.end.loopexit_crit_edge

%for.cond.for.end.loopexit_crit_edge:
  br label %for.end.loopexit

%for.end.loopexit:
  br label %for.end

%for.end:
  %4 = load i32, * @idx, align 4
  ret i32 %4
}
=>
@idx = global 4 bytes, align 4
@e = global 4 bytes, align 4
@ptr = global 8 bytes, align 8

define i32 @test1() {
%entry:
  store i32 4294967295, * @idx, align 4
  %0 = load i32, * @e, align 4
  %cmp4 = icmp slt i32 %0, 0
  br i1 %cmp4, label %for.end.loopexit, label %for.body.lr.ph

%for.body.lr.ph:
  %1 = load *, * @ptr, align 8
  %2 = load i32, * @e, align 4
  %3 = icmp sgt i32 %2, 0
  %smax = select i1 %3, i32 %2, i32 0
  %4 = add nuw i32 %smax, 1
  %wide.trip.count = zext i32 %4 to i64
  br label %for.body

%for.body:
  %indvars.iv = phi i64 [ 0, %for.body.lr.ph ], [ %indvars.iv.next, %for.cond ]
  %arrayidx = gep inbounds * %1, 4 x i64 %indvars.iv
  %5 = load i32, * %arrayidx, align 4
  %tobool = icmp eq i32 %5, 0
  br i1 %tobool, label %if.then, label %for.cond

%if.then:
  %i.05.lcssa.wide = phi i64 [ %indvars.iv, %for.body ]
  %6 = trunc i64 %i.05.lcssa.wide to i32
  store i32 %6, * @idx, align 4
  br label %for.end

%for.cond:
  %indvars.iv.next = add nsw nuw i64 %indvars.iv, 1
  %exitcond = icmp ne i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond, label %for.body, label %for.cond.for.end.loopexit_crit_edge

%for.cond.for.end.loopexit_crit_edge:
  br label %for.end.loopexit

%for.end.loopexit:
  br label %for.end

%for.end:
  %7 = load i32, * @idx, align 4
  ret i32 %7
}
Transformation seems to be correct!


----------------------------------------
define void @test2(* %a, * %b, i8 %limit) {
%entry:
  %conv = zext i8 %limit to i32
  br i1 undef, label %for.cond1.preheader, label %for.cond1.preheader.us

%for.cond1.preheader.us:
  %storemerge5.us = phi i32 [ 0, %entry ], [ %inc14.us, %for.inc13.us ]
  br i1 1, label %for.body4.lr.ph.us, label %for.inc13.us

%for.body4.lr.ph.us:
  %idxprom5.us = sext i32 %storemerge5.us to i64
  br label %for.body4.us

%for.body4.us:
  %storemerge14.us = phi i32 [ 0, %for.body4.lr.ph.us ], [ %inc.us, %for.body4.us ]
  %idxprom.us = sext i32 %storemerge14.us to i64
  %arrayidx6.us = gep inbounds * %a, 8 x i64 %idxprom5.us, 1 x i64 %idxprom.us
  %0 = load i8, * %arrayidx6.us, align 1
  %idxprom7.us = zext i8 %0 to i64
  %arrayidx8.us = gep inbounds * %b, 1 x i64 %idxprom7.us
  %1 = load i8, * %arrayidx8.us, align 1
  store i8 %1, * %arrayidx6.us, align 1
  %inc.us = add nsw i32 %storemerge14.us, 1
  %cmp2.us = icmp slt i32 %inc.us, %conv
  br i1 %cmp2.us, label %for.body4.us, label %for.inc13.us

%for.inc13.us:
  %inc14.us = add nsw i32 %storemerge5.us, 1
  %cmp.us = icmp slt i32 %inc14.us, 4
  br i1 %cmp.us, label %for.cond1.preheader.us, label %for.end

%for.cond1.preheader:
  %storemerge5 = phi i32 [ 0, %entry ], [ %inc14, %for.inc13 ]
  br i1 0, label %for.inc13, label %for.inc13

%for.inc13:
  %inc14 = add nsw i32 %storemerge5, 1
  %cmp = icmp slt i32 %inc14, 4
  br i1 %cmp, label %for.cond1.preheader, label %for.end

%for.end:
  ret void
}
=>
define void @test2(* %a, * %b, i8 %limit) {
%entry:
  %conv = zext i8 %limit to i32
  br i1 undef, label %for.cond1.preheader.preheader, label %for.cond1.preheader.us.preheader

%for.cond1.preheader.us.preheader:
  %0 = icmp sgt i32 %conv, 1
  %smax = select i1 %0, i32 %conv, i32 1
  br label %for.cond1.preheader.us

%for.cond1.preheader.us:
  %indvars.iv2 = phi i64 [ 0, %for.cond1.preheader.us.preheader ], [ %indvars.iv.next3, %for.inc13.us ]
  br i1 1, label %for.body4.lr.ph.us, label %for.inc13.us

%for.body4.lr.ph.us:
  %wide.trip.count = zext i32 %smax to i64
  br label %for.body4.us

%for.body4.us:
  %indvars.iv = phi i64 [ 0, %for.body4.lr.ph.us ], [ %indvars.iv.next, %for.body4.us ]
  %arrayidx6.us = gep inbounds * %a, 8 x i64 %indvars.iv2, 1 x i64 %indvars.iv
  %1 = load i8, * %arrayidx6.us, align 1
  %idxprom7.us = zext i8 %1 to i64
  %arrayidx8.us = gep inbounds * %b, 1 x i64 %idxprom7.us
  %2 = load i8, * %arrayidx8.us, align 1
  store i8 %2, * %arrayidx6.us, align 1
  %indvars.iv.next = add nsw nuw i64 %indvars.iv, 1
  %exitcond = icmp ne i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond, label %for.body4.us, label %for.inc13.us.loopexit

%for.inc13.us.loopexit:
  br label %for.inc13.us

%for.inc13.us:
  %indvars.iv.next3 = add nsw nuw i64 %indvars.iv2, 1
  %exitcond4 = icmp ne i64 %indvars.iv.next3, 4
  br i1 %exitcond4, label %for.cond1.preheader.us, label %for.end.loopexit1

%for.end.loopexit1:
  br label %for.end

%for.cond1.preheader.preheader:
  br label %for.cond1.preheader

%for.cond1.preheader:
  br i1 0, label %for.inc13, label %for.inc13

%for.inc13:
  br i1 0, label %for.cond1.preheader, label %for.end.loopexit

%for.end.loopexit:
  br label %for.end

%for.end:
  ret void
}
Transformation seems to be correct!


----------------------------------------
define i32 @test3(* %a, i32 %b) {
%entry:
  br label %for.cond

%for.cond:
  %sum.0 = phi i32 [ 0, %entry ], [ %add, %for.body ]
  %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
  %cmp = icmp slt i32 %i.0, %b
  br i1 %cmp, label %for.body, label %for.end

%for.body:
  %idxprom = sext i32 %i.0 to i64
  %arrayidx = gep inbounds * %a, 4 x i64 %idxprom
  %0 = load i32, * %arrayidx, align 4
  %add = add nsw i32 %sum.0, %0
  %inc = add nsw i32 %i.0, 1
  br label %for.cond

%for.end:
  ret i32 %sum.0
}
=>
define i32 @test3(* %a, i32 %b) {
%entry:
  %0 = icmp sgt i32 %b, 0
  %smax = select i1 %0, i32 %b, i32 0
  %wide.trip.count = zext i32 %smax to i64
  br label %for.cond

%for.cond:
  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
  %sum.0 = phi i32 [ 0, %entry ], [ %add, %for.body ]
  %exitcond = icmp ne i64 %indvars.iv, %wide.trip.count
  br i1 %exitcond, label %for.body, label %for.end

%for.body:
  %arrayidx = gep inbounds * %a, 4 x i64 %indvars.iv
  %1 = load i32, * %arrayidx, align 4
  %add = add nsw i32 %sum.0, %1
  %indvars.iv.next = add nsw nuw i64 %indvars.iv, 1
  br label %for.cond

%for.end:
  %sum.0.lcssa = phi i32 [ %sum.0, %for.cond ]
  ret i32 %sum.0.lcssa
}
Transformation seems to be correct!


----------------------------------------
define i32 @test4(i32 %a) {
%entry:
  br label %for.body

%for.body:
  %c.07 = phi i8 [ 253, %entry ], [ %dec, %for.body ]
  %conv6 = zext i8 %c.07 to i32
  %or = or i32 %a, %conv6
  %conv3 = trunc i32 %or to i8
  %call = call i32 @fn1(i8 %conv3)
  %dec = add i8 %c.07, 255
  %cmp = icmp sgt i8 %dec, 242
  br i1 %cmp, label %for.body, label %for.end

%for.end:
  ret i32 0
}
=>
define i32 @test4(i32 %a) {
%entry:
  br label %for.body

%for.body:
  %indvars.iv = phi i32 [ 253, %entry ], [ %indvars.iv.next, %for.body ]
  %or = or i32 %a, %indvars.iv
  %conv3 = trunc i32 %or to i8
  %call = call i32 @fn1(i8 %conv3)
  %indvars.iv.next = add nsw i32 %indvars.iv, 4294967295
  %0 = trunc i32 %indvars.iv.next to i8
  %cmp = icmp sgt i8 %0, 242
  br i1 %cmp, label %for.body, label %for.end

%for.end:
  ret i32 0
}
Transformation doesn't verify!
ERROR: The source program doesn't reach a return instruction.
Consider increasing the unroll factor if it has loops


----------------------------------------
define i32 @test5(* %a, i32 %b) {
%entry:
  br label %for.cond

%for.cond:
  %sum.0 = phi i32 [ 0, %entry ], [ %add, %for.body ]
  %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
  %cmp = icmp ule i32 %i.0, %b
  br i1 %cmp, label %for.body, label %for.end

%for.body:
  %idxprom = zext i32 %i.0 to i64
  %arrayidx = gep inbounds * %a, 4 x i64 %idxprom
  %0 = load i32, * %arrayidx, align 4
  %add = add nsw i32 %sum.0, %0
  %inc = add nsw i32 %i.0, 1
  br label %for.cond

%for.end:
  ret i32 %sum.0
}
=>
define i32 @test5(* %a, i32 %b) {
%entry:
  %0 = zext i32 %b to i64
  br label %for.cond

%for.cond:
  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
  %sum.0 = phi i32 [ 0, %entry ], [ %add, %for.body ]
  %cmp = icmp ule i64 %indvars.iv, %0
  br i1 %cmp, label %for.body, label %for.end

%for.body:
  %arrayidx = gep inbounds * %a, 4 x i64 %indvars.iv
  %1 = load i32, * %arrayidx, align 4
  %add = add nsw i32 %sum.0, %1
  %indvars.iv.next = add nuw i64 %indvars.iv, 1
  br label %for.cond

%for.end:
  %sum.0.lcssa = phi i32 [ %sum.0, %for.cond ]
  ret i32 %sum.0.lcssa
}
Transformation doesn't verify!
ERROR: The source program doesn't reach a return instruction.
Consider increasing the unroll factor if it has loops


----------------------------------------
define i32 @test6(* %a, i32 %b) {
%entry:
  br label %for.cond

%for.cond:
  %sum.0 = phi i32 [ 0, %entry ], [ %add, %for.body ]
  %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
  %cmp = icmp sle i32 %i.0, %b
  br i1 %cmp, label %for.body, label %for.end

%for.body:
  %idxprom = zext i32 %i.0 to i64
  %arrayidx = gep inbounds * %a, 4 x i64 %idxprom
  %0 = load i32, * %arrayidx, align 4
  %add = add nsw i32 %sum.0, %0
  %inc = add nsw i32 %i.0, 1
  br label %for.cond

%for.end:
  ret i32 %sum.0
}
=>
define i32 @test6(* %a, i32 %b) {
%entry:
  %0 = icmp sgt i32 %b, 4294967295
  %smax = select i1 %0, i32 %b, i32 4294967295
  %1 = add i32 %smax, 1
  %wide.trip.count = zext i32 %1 to i64
  br label %for.cond

%for.cond:
  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
  %sum.0 = phi i32 [ 0, %entry ], [ %add, %for.body ]
  %exitcond = icmp ne i64 %indvars.iv, %wide.trip.count
  br i1 %exitcond, label %for.body, label %for.end

%for.body:
  %arrayidx = gep inbounds * %a, 4 x i64 %indvars.iv
  %2 = load i32, * %arrayidx, align 4
  %add = add nsw i32 %sum.0, %2
  %indvars.iv.next = add nsw nuw i64 %indvars.iv, 1
  br label %for.cond

%for.end:
  %sum.0.lcssa = phi i32 [ %sum.0, %for.cond ]
  ret i32 %sum.0.lcssa
}
Transformation seems to be correct!


----------------------------------------
define i32 @test7(* %a, i32 %b) {
%entry:
  br label %for.cond

%for.cond:
  %sum.0 = phi i32 [ 0, %entry ], [ %add, %for.body ]
  %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
  %cmp = icmp ule i32 %i.0, %b
  br i1 %cmp, label %for.body, label %for.end

%for.body:
  %idxprom = sext i32 %i.0 to i64
  %arrayidx = gep inbounds * %a, 4 x i64 %idxprom
  %0 = load i32, * %arrayidx, align 4
  %add = add nsw i32 %sum.0, %0
  %inc = add nsw i32 %i.0, 1
  %cmp2 = icmp sle i32 %i.0, %b
  br i1 %cmp2, label %for.cond, label %for.end

%for.end:
  ret i32 %sum.0
}
=>
define i32 @test7(* %a, i32 %b) {
%entry:
  %0 = zext i32 %b to i64
  %1 = icmp sgt i32 %b, 4294967295
  %smax = select i1 %1, i32 %b, i32 4294967295
  %2 = add i32 %smax, 2
  %wide.trip.count = zext i32 %2 to i64
  br label %for.cond

%for.cond:
  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
  %sum.0 = phi i32 [ 0, %entry ], [ %add, %for.body ]
  %cmp = icmp ule i64 %indvars.iv, %0
  br i1 %cmp, label %for.body, label %for.end

%for.body:
  %arrayidx = gep inbounds * %a, 4 x i64 %indvars.iv
  %3 = load i32, * %arrayidx, align 4
  %add = add nsw i32 %sum.0, %3
  %indvars.iv.next = add nsw nuw i64 %indvars.iv, 1
  %exitcond = icmp ne i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond, label %for.cond, label %for.end

%for.end:
  %sum.0.lcssa = phi i32 [ %sum.0, %for.body ], [ %sum.0, %for.cond ]
  ret i32 %sum.0.lcssa
}
Transformation seems to be correct!


----------------------------------------
define i32 @test8(* %a, i32 %b, i32 %init) {
%entry:
  %e = icmp sgt i32 %init, 0
  br i1 %e, label %for.cond, label %leave

%leave:
  ret i32 0

%for.cond:
  %sum.0 = phi i32 [ 0, %entry ], [ %add, %for.body ]
  %i.0 = phi i32 [ %init, %entry ], [ %inc, %for.body ]
  %cmp = icmp ule i32 %i.0, %b
  br i1 %cmp, label %for.body, label %for.end

%for.body:
  %idxprom = sext i32 %i.0 to i64
  %arrayidx = gep inbounds * %a, 4 x i64 %idxprom
  %0 = load i32, * %arrayidx, align 4
  %add = add nsw i32 %sum.0, %0
  %inc = add nsw i32 %i.0, 1
  %cmp2 = icmp slt i32 0, %inc
  br i1 %cmp2, label %for.cond, label %for.end

%for.end:
  ret i32 %sum.0
}
=>
define i32 @test8(* %a, i32 %b, i32 %init) {
%entry:
  %e = icmp sgt i32 %init, 0
  br i1 %e, label %for.cond.preheader, label %leave

%leave:
  ret i32 0

%for.cond.preheader:
  %0 = sext i32 %init to i64
  %1 = zext i32 %b to i64
  br label %for.cond

%for.cond:
  %indvars.iv = phi i64 [ %0, %for.cond.preheader ], [ %indvars.iv.next, %for.body ]
  %sum.0 = phi i32 [ 0, %for.cond.preheader ], [ %add, %for.body ]
  %cmp = icmp ule i64 %indvars.iv, %1
  br i1 %cmp, label %for.body, label %for.end

%for.body:
  %arrayidx = gep inbounds * %a, 4 x i64 %indvars.iv
  %2 = load i32, * %arrayidx, align 4
  %add = add nsw i32 %sum.0, %2
  %indvars.iv.next = add i64 %indvars.iv, 1
  %cmp2 = icmp slt i64 0, %indvars.iv.next
  br i1 %cmp2, label %for.cond, label %for.end

%for.end:
  %sum.0.lcssa = phi i32 [ %sum.0, %for.body ], [ %sum.0, %for.cond ]
  ret i32 %sum.0.lcssa
}
Transformation seems to be correct!


----------------------------------------
define i32 @test9(* %a, i32 %b, i32 %init) {
%entry:
  %e = icmp sgt i32 %init, 0
  br i1 %e, label %for.cond, label %leave

%leave:
  ret i32 0

%for.cond:
  %sum.0 = phi i32 [ 0, %entry ], [ %add, %for.body ]
  %i.0 = phi i32 [ %init, %entry ], [ %inc, %for.body ]
  %cmp = icmp slt i32 %i.0, %b
  br i1 %cmp, label %for.body, label %for.end

%for.body:
  %idxprom = zext i32 %i.0 to i64
  %arrayidx = gep inbounds * %a, 4 x i64 %idxprom
  %0 = load i32, * %arrayidx, align 4
  %add = add nsw i32 %sum.0, %0
  %inc = add nsw i32 %i.0, 1
  %cmp2 = icmp slt i32 0, %inc
  br i1 %cmp2, label %for.cond, label %for.end

%for.end:
  ret i32 %sum.0
}
=>
define i32 @test9(* %a, i32 %b, i32 %init) {
%entry:
  %e = icmp sgt i32 %init, 0
  br i1 %e, label %for.cond.preheader, label %leave

%leave:
  ret i32 0

%for.cond.preheader:
  %0 = zext i32 %init to i64
  %1 = icmp sgt i32 %init, %b
  %smax = select i1 %1, i32 %init, i32 %b
  %wide.trip.count = zext i32 %smax to i64
  br label %for.cond

%for.cond:
  %indvars.iv = phi i64 [ %0, %for.cond.preheader ], [ %indvars.iv.next, %for.body ]
  %sum.0 = phi i32 [ 0, %for.cond.preheader ], [ %add, %for.body ]
  %exitcond = icmp ne i64 %indvars.iv, %wide.trip.count
  br i1 %exitcond, label %for.body, label %for.end

%for.body:
  %arrayidx = gep inbounds * %a, 4 x i64 %indvars.iv
  %2 = load i32, * %arrayidx, align 4
  %add = add nsw i32 %sum.0, %2
  %indvars.iv.next = add nsw nuw i64 %indvars.iv, 1
  %3 = trunc i64 %indvars.iv.next to i32
  %cmp2 = icmp slt i32 0, %3
  br i1 %cmp2, label %for.cond, label %for.end

%for.end:
  %sum.0.lcssa = phi i32 [ %sum.0, %for.body ], [ %sum.0, %for.cond ]
  ret i32 %sum.0.lcssa
}
Transformation doesn't verify!
ERROR: Source is more defined than target

Example:
* %a = poison
i32 %b = undef
i32 %init = #x7fffffff (2147483647)

Source:
i1 %e = #x1 (1)
i32 %sum.0 = #x00000000 (0)
i32 %i.0 = #x7fffffff (2147483647)
i1 %cmp = #x0 (0)
i64 %idxprom = #x000000007fffffff (2147483647)
* %arrayidx = poison
i32 %0 = poison
i32 %add = poison
i32 %inc = poison
i1 %cmp2 = poison

SOURCE MEMORY STATE
===================
NON-LOCAL BLOCKS:
Block 0 >	size: 0	align: 4	alloc type: 0
Block 1 >	align: 4	alloc type: 0

Target:
i1 %e = #x1 (1)
i64 %0 = #x000000007fffffff (2147483647)
i1 %1 = #x0 (0)
i32 %smax = #x00000100 (256)
i64 %wide.trip.count = #x0000000000000100 (256)
i64 %indvars.iv = #x000000007fffffff (2147483647)
i32 %sum.0 = #x00000000 (0)
i1 %exitcond = #x1 (1)
* %arrayidx = poison
i32 %2 = poison
i32 %add = poison
i64 %indvars.iv.next = #x0000000080000000 (2147483648)
i32 %3 = #x80000000 (2147483648, -2147483648)
i1 %cmp2 = #x0 (0)
i32 %sum.0.lcssa = #x00000000 (0)



------------------- SMT STATS -------------------
Num queries: 13
Num invalid: 0
Num skips:   0
Num trivial: 31 (70.5%)
Num timeout: 0 (0.0%)
Num errors:  0 (0.0%)
Num SAT:     8 (61.5%)
Num UNSAT:   5 (38.5%)

stderr:

+ : 'RUN: at line 2'
+ /home/nlopes/alive2/build/opt-alive.sh -indvars -scalar-evolution-use-expensive-range-sharpening -S
+ /home/nlopes/llvm/build/bin/FileCheck --allow-unused-prefixes=false /home/nlopes/llvm/llvm/test/Transforms/IndVarSimplify/widen-loop-comp.ll

Alive2: Transform doesn't verify; aborting!
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /home/nlopes/llvm/build/bin/FileCheck --allow-unused-prefixes=false /home/nlopes/llvm/llvm/test/Transforms/IndVarSimplify/widen-loop-comp.ll

 

NOTE: This test would pass if undef didn't exist!

 

<-- Back