Test Failure: Transforms/SimpleLoopUnswitch/trivial-unswitch.ll

Test source: git

Log:

Source: <stdin>
ERROR: Unsupported instruction:   %cond2 = load volatile i1, i1* %cond2.ptr, align 1

----------------------------------------
define i32 @test1(* %var, i1 %cond1, i1 %cond2) {
%entry:
  br label %loop_begin

%loop_begin:
  br i1 %cond1, label %continue, label %loop_exit

%continue:
  %var_val = load i32, * %var, align 4
  br i1 %cond2, label %do_something, label %loop_exit

%do_something:
  call void @some_func() noreturn
  br label %loop_begin

%loop_exit:
  ret i32 0
}
=>
define i32 @test1(* %var, i1 %cond1, i1 %cond2) {
%entry:
  br i1 %cond1, label %entry.split, label %loop_exit.split

%entry.split:
  br i1 %cond2, label %entry.split.split, label %loop_exit

%entry.split.split:
  br label %loop_begin

%loop_begin:
  br label %continue

%continue:
  %var_val = load i32, * %var, align 4
  br label %do_something

%do_something:
  call void @some_func() noreturn
  br label %loop_begin

%loop_exit:
  br label %loop_exit.split

%loop_exit.split:
  ret i32 0
}
Transformation seems to be correct!


----------------------------------------
define i32 @test3(* %var, i32 %cond1, i32 %cond2) {
%entry:
  br label %loop_begin

%loop_begin:
  switch i32 %cond1, label %continue [
    i32 0, label %loop_exit1
  ]

%continue:
  %var_val = load i32, * %var, align 4
  switch i32 %cond2, label %loop_exit2 [
    i32 0, label %do_something
    i32 42, label %loop_exit2
  ]

%loop_exit2:
  ret i32 0

%do_something:
  call void @some_func() noreturn
  br label %loop_begin

%loop_exit1:
  ret i32 0
}
=>
define i32 @test3(* %var, i32 %cond1, i32 %cond2) {
%entry:
  switch i32 %cond1, label %entry.split [
    i32 0, label %loop_exit1
  ]

%loop_exit1:
  ret i32 0

%entry.split:
  switch i32 %cond2, label %loop_exit2 [
    i32 42, label %loop_exit2
    i32 0, label %entry.split.split
  ]

%loop_exit2:
  ret i32 0

%entry.split.split:
  br label %loop_begin

%loop_begin:
  br label %continue

%continue:
  %var_val = load i32, * %var, align 4
  br label %do_something

%do_something:
  call void @some_func() noreturn
  br label %loop_begin
}
Transformation seems to be correct!


----------------------------------------
define i32 @test4(* %var, i32 %cond1, i32 %cond2) {
%entry:
  br label %loop_begin

%loop_begin:
  %var_val = load i32, * %var, align 4
  switch i32 %cond2, label %loop_exit2 [
    i32 0, label %loop0
    i32 1, label %loop1
    i32 13, label %loop_exit1
    i32 2, label %loop2
    i32 42, label %loop_exit3
  ]

%loop_exit2:
  ret i32 0

%loop0:
  call void @some_func() noreturn
  br label %loop_latch

%loop1:
  call void @some_func() noreturn
  br label %loop_latch

%loop_exit1:
  ret i32 0

%loop2:
  call void @some_func() noreturn
  br label %loop_latch

%loop_latch:
  br label %loop_begin

%loop_exit3:
  ret i32 0
}
=>
define i32 @test4(* %var, i32 %cond1, i32 %cond2) {
%entry:
  switch i32 %cond2, label %loop_exit2 [
    i32 13, label %loop_exit1
    i32 42, label %loop_exit3
    i32 0, label %entry.split
    i32 1, label %entry.split
    i32 2, label %entry.split
  ]

%entry.split:
  br label %loop_begin

%loop_begin:
  %var_val = load i32, * %var, align 4
  switch i32 %cond2, label %loop2 [
    i32 0, label %loop0
    i32 1, label %loop1
  ]

%loop2:
  call void @some_func() noreturn
  br label %loop_latch

%loop0:
  call void @some_func() noreturn
  br label %loop_latch

%loop1:
  call void @some_func() noreturn
  br label %loop_latch

%loop_latch:
  br label %loop_begin

%loop_exit3:
  ret i32 0

%loop_exit1:
  ret i32 0

%loop_exit2:
  ret i32 0
}
Transformation seems to be correct!


----------------------------------------
define i32 @test5(i1 %cond1, i32 %x, i32 %y) {
%entry:
  br label %loop_begin

%loop_begin:
  br i1 %cond1, label %latch, label %loop_exit

%latch:
  call void @some_func() noreturn
  br label %loop_begin

%loop_exit:
  %result1 = phi i32 [ %x, %loop_begin ]
  %result2 = phi i32 [ %y, %loop_begin ]
  %result = add i32 %result1, %result2
  ret i32 %result
}
=>
define i32 @test5(i1 %cond1, i32 %x, i32 %y) {
%entry:
  br i1 %cond1, label %entry.split, label %loop_exit

%loop_exit:
  %result1 = phi i32 [ %x, %entry ]
  %result2 = phi i32 [ %y, %entry ]
  %result = add i32 %result1, %result2
  ret i32 %result

%entry.split:
  br label %loop_begin

%loop_begin:
  br label %latch

%latch:
  call void @some_func() noreturn
  br label %loop_begin
}
Transformation seems to be correct!


----------------------------------------
define i32 @test6(* %var, i1 %cond1, i1 %cond2, i32 %x, i32 %y) {
%entry:
  br label %loop_begin

%loop_begin:
  br i1 %cond1, label %continue, label %loop_exit

%continue:
  %var_val = load i32, * %var, align 4
  br i1 %cond2, label %latch, label %loop_exit

%latch:
  call void @some_func() noreturn
  br label %loop_begin

%loop_exit:
  %result1 = phi i32 [ %x, %loop_begin ], [ %var_val, %continue ]
  %result2 = phi i32 [ %var_val, %continue ], [ %y, %loop_begin ]
  %result = add i32 %result1, %result2
  ret i32 %result
}
=>
define i32 @test6(* %var, i1 %cond1, i1 %cond2, i32 %x, i32 %y) {
%entry:
  br i1 %cond1, label %entry.split, label %loop_exit.split

%entry.split:
  br label %loop_begin

%loop_begin:
  br label %continue

%continue:
  %var_val = load i32, * %var, align 4
  br i1 %cond2, label %latch, label %loop_exit

%latch:
  call void @some_func() noreturn
  br label %loop_begin

%loop_exit:
  %result1 = phi i32 [ %var_val, %continue ]
  %result2 = phi i32 [ %var_val, %continue ]
  br label %loop_exit.split

%loop_exit.split:
  %result1.split = phi i32 [ %x, %entry ], [ %result1, %loop_exit ]
  %result2.split = phi i32 [ %y, %entry ], [ %result2, %loop_exit ]
  %result = add i32 %result1.split, %result2.split
  ret i32 %result
}
Transformation seems to be correct!


----------------------------------------
define i32 @test7(i32 %cond1, i32 %x, i32 %y) {
%entry:
  br label %loop_begin

%loop_begin:
  switch i32 %cond1, label %latch [
    i32 0, label %loop_exit
    i32 1, label %loop_exit
  ]

%latch:
  call void @some_func() noreturn
  br label %loop_begin

%loop_exit:
  %result1 = phi i32 [ %x, %loop_begin ], [ %x, %loop_begin ]
  %result2 = phi i32 [ %y, %loop_begin ], [ %y, %loop_begin ]
  %result = add i32 %result1, %result2
  ret i32 %result
}
=>
define i32 @test7(i32 %cond1, i32 %x, i32 %y) {
%entry:
  switch i32 %cond1, label %entry.split [
    i32 0, label %loop_exit
    i32 1, label %loop_exit
  ]

%loop_exit:
  %result1 = phi i32 [ %x, %entry ], [ %x, %entry ]
  %result2 = phi i32 [ %y, %entry ], [ %y, %entry ]
  %result = add i32 %result1, %result2
  ret i32 %result

%entry.split:
  br label %loop_begin

%loop_begin:
  br label %latch

%latch:
  call void @some_func() noreturn
  br label %loop_begin
}
Transformation seems to be correct!


----------------------------------------
define i32 @test8(* %var, i32 %cond1, i32 %cond2, i32 %x, i32 %y) {
%entry:
  br label %loop_begin

%loop_begin:
  switch i32 %cond1, label %continue [
    i32 0, label %loop_exit
    i32 1, label %loop_exit2
    i32 2, label %loop_exit
  ]

%continue:
  %var_val = load i32, * %var, align 4
  switch i32 %cond2, label %latch [
    i32 0, label %loop_exit
  ]

%latch:
  call void @some_func() noreturn
  br label %loop_begin

%loop_exit:
  %result1.1 = phi i32 [ %x, %loop_begin ], [ %x, %loop_begin ], [ %var_val, %continue ]
  %result1.2 = phi i32 [ %var_val, %continue ], [ %y, %loop_begin ], [ %y, %loop_begin ]
  %result1 = add i32 %result1.1, %result1.2
  ret i32 %result1

%loop_exit2:
  %result2.1 = phi i32 [ %x, %loop_begin ]
  %result2.2 = phi i32 [ %y, %loop_begin ]
  %result2 = add i32 %result2.1, %result2.2
  ret i32 %result2
}
=>
define i32 @test8(* %var, i32 %cond1, i32 %cond2, i32 %x, i32 %y) {
%entry:
  switch i32 %cond1, label %entry.split [
    i32 0, label %loop_exit.split
    i32 1, label %loop_exit2
    i32 2, label %loop_exit.split
  ]

%loop_exit2:
  %result2.1 = phi i32 [ %x, %entry ]
  %result2.2 = phi i32 [ %y, %entry ]
  %result2 = add i32 %result2.1, %result2.2
  ret i32 %result2

%entry.split:
  br label %loop_begin

%loop_begin:
  br label %continue

%continue:
  %var_val = load i32, * %var, align 4
  switch i32 %cond2, label %latch [
    i32 0, label %loop_exit
  ]

%latch:
  call void @some_func() noreturn
  br label %loop_begin

%loop_exit:
  %result1.1 = phi i32 [ %var_val, %continue ]
  %result1.2 = phi i32 [ %var_val, %continue ]
  br label %loop_exit.split

%loop_exit.split:
  %result1.1.split = phi i32 [ %x, %entry ], [ %x, %entry ], [ %result1.1, %loop_exit ]
  %result1.2.split = phi i32 [ %y, %entry ], [ %y, %entry ], [ %result1.2, %loop_exit ]
  %result1 = add i32 %result1.1.split, %result1.2.split
  ret i32 %result1
}
Transformation doesn't verify!
ERROR: Timeout

ERROR: Unsupported instruction:   %cond2 = load volatile i1, i1* %cond2.ptr, align 1

----------------------------------------
define i32 @test_partial_condition_unswitch_and(* %var, i1 %cond1, i1 %cond2) {
%entry:
  br label %loop_begin

%loop_begin:
  br i1 %cond1, label %continue, label %loop_exit

%continue:
  %var_val = load i32, * %var, align 4
  %var_cond = trunc i32 %var_val to i1
  %cond_and = and i1 %var_cond, %cond2
  br i1 %cond_and, label %do_something, label %loop_exit

%do_something:
  call void @some_func() noreturn
  br label %loop_begin

%loop_exit:
  ret i32 0
}
=>
define i32 @test_partial_condition_unswitch_and(* %var, i1 %cond1, i1 %cond2) {
%entry:
  br i1 %cond1, label %entry.split, label %loop_exit.split

%entry.split:
  br i1 %cond2, label %entry.split.split, label %loop_exit.split1

%entry.split.split:
  br label %loop_begin

%loop_begin:
  br label %continue

%continue:
  %var_val = load i32, * %var, align 4
  %var_cond = trunc i32 %var_val to i1
  %cond_and = and i1 %var_cond, 1
  br i1 %cond_and, label %do_something, label %loop_exit

%do_something:
  call void @some_func() noreturn
  br label %loop_begin

%loop_exit:
  br label %loop_exit.split1

%loop_exit.split1:
  br label %loop_exit.split

%loop_exit.split:
  ret i32 0
}
Transformation doesn't verify!
ERROR: Source is more defined than target

Example:
* %var = pointer(non-local, block_id=1, offset=0)
i1 %cond1 = #x1 (1)
i1 %cond2 = undef

Source:
i32 %var_val = #x00000000 (0)
i1 %var_cond = #x0 (0)
i1 %cond_and = #x0 (0)

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

Target:
i32 %var_val = #x00000000 (0)
i1 %var_cond = #x0 (0)
i1 %cond_and = #x0 (0)



------------------- SMT STATS -------------------
Num queries: 30
Num invalid: 0
Num skips:   0
Num trivial: 29 (49.2%)
Num timeout: 1 (3.3%)
Num errors:  0 (0.0%)
Num SAT:     9 (30.0%)
Num UNSAT:   20 (66.7%)
Alive2: Transform doesn't verify; aborting!

stderr:

+ : 'RUN: at line 1'
+ /home/nlopes/alive2/build/opt-alive.sh '-passes=loop(unswitch),verify<loops>' -S
+ /home/nlopes/llvm/build/bin/FileCheck /home/nlopes/llvm/llvm/test/Transforms/SimpleLoopUnswitch/trivial-unswitch.ll

FileCheck error: '<stdin>' is empty.
FileCheck command line:  /home/nlopes/llvm/build/bin/FileCheck /home/nlopes/llvm/llvm/test/Transforms/SimpleLoopUnswitch/trivial-unswitch.ll

 

<-- Back