Test Failure: Transforms/GVN/condprop.ll

Test source: git

Comments: LLVM bug: incorrect propagation of pointer equality

Log:

Source: <stdin>
ERROR: Unsupported attribute: noalias

----------------------------------------
@a = global 4 bytes, align 4

define i32 @test1() {
%entry:
  %0 = load i32, ptr @a, align 4
  %1 = icmp eq i32 %0, 4
  br i1 %1, label %bb, label %bb1

%bb1:
  %2 = load i32, ptr @a, align 4
  %3 = icmp eq i32 %2, 5
  br i1 %3, label %bb2, label %bb3

%bb2:
  br label %bb8

%bb3:
  %4 = load i32, ptr @a, align 4
  %5 = icmp eq i32 %4, 4
  br i1 %5, label %bb4, label %bb5

%bb4:
  %6 = load i32, ptr @a, align 4
  %7 = add i32 %6, 5
  br label %bb8

%bb5:
  %8 = load i32, ptr @a, align 4
  %9 = icmp eq i32 %8, 5
  br i1 %9, label %bb6, label %bb7

%bb6:
  %10 = load i32, ptr @a, align 4
  %11 = add i32 %10, 4
  br label %bb8

%bb7:
  %12 = load i32, ptr @a, align 4
  br label %bb8

%bb:
  br label %bb8

%bb8:
  %.0 = phi i32 [ %12, %bb7 ], [ %11, %bb6 ], [ %7, %bb4 ], [ 4, %bb2 ], [ 5, %bb ]
  br label %return

%return:
  ret i32 %.0
}
=>
@a = global 4 bytes, align 4

define i32 @test1() {
%entry:
  %0 = load i32, ptr @a, align 4
  %1 = icmp eq i32 %0, 4
  br i1 %1, label %bb, label %bb1

%bb1:
  %2 = icmp eq i32 %0, 5
  br i1 %2, label %bb2, label %bb3

%bb2:
  br label %bb8

%bb3:
  br i1 0, label %bb4, label %bb5

%bb4:
  %3 = load i32, ptr @a, align 4
  %4 = add i32 %3, 5
  br label %bb8

%bb5:
  br i1 0, label %bb6, label %bb7

%bb6:
  %5 = load i32, ptr @a, align 4
  %6 = add i32 %5, 4
  br label %bb8

%bb7:
  br label %bb8

%bb:
  br label %bb8

%bb8:
  %.0 = phi i32 [ %0, %bb7 ], [ poison, %bb6 ], [ poison, %bb4 ], [ 4, %bb2 ], [ 5, %bb ]
  ret i32 %.0
}
Transformation seems to be correct!


----------------------------------------
define void @test3(i32 %x, i32 %y) {
%0:
  %xz = icmp eq i32 %x, 0
  %yz = icmp eq i32 %y, 0
  %z = and i1 %xz, %yz
  br i1 %z, label %both_zero, label %nope

%nope:
  call void @foo(i1 %z)
  ret void

%both_zero:
  call void @foo(i1 %xz)
  call void @foo(i1 %yz)
  call void @bar(i32 %x)
  call void @bar(i32 %y)
  ret void
}
=>
define void @test3(i32 %x, i32 %y) {
%0:
  %xz = icmp eq i32 %x, 0
  %yz = icmp eq i32 %y, 0
  %z = and i1 %xz, %yz
  br i1 %z, label %both_zero, label %nope

%nope:
  call void @foo(i1 0)
  ret void

%both_zero:
  call void @foo(i1 1)
  call void @foo(i1 1)
  call void @bar(i32 0)
  call void @bar(i32 0)
  ret void
}
Transformation seems to be correct!


----------------------------------------
define void @test3_select(i32 %x, i32 %y) {
%0:
  %xz = icmp eq i32 %x, 0
  %yz = icmp eq i32 %y, 0
  %z = select i1 %xz, i1 %yz, i1 0
  br i1 %z, label %both_zero, label %nope

%nope:
  call void @foo(i1 %z)
  ret void

%both_zero:
  call void @foo(i1 %xz)
  call void @foo(i1 %yz)
  call void @bar(i32 %x)
  call void @bar(i32 %y)
  ret void
}
=>
define void @test3_select(i32 %x, i32 %y) {
%0:
  %xz = icmp eq i32 %x, 0
  %yz = icmp eq i32 %y, 0
  %z = select i1 %xz, i1 %yz, i1 0
  br i1 %z, label %both_zero, label %nope

%nope:
  call void @foo(i1 0)
  ret void

%both_zero:
  call void @foo(i1 1)
  call void @foo(i1 1)
  call void @bar(i32 0)
  call void @bar(i32 0)
  ret void
}
Transformation seems to be correct!


----------------------------------------
define void @test3_or(i32 %x, i32 %y) {
%0:
  %xz = icmp ne i32 %x, 0
  %yz = icmp ne i32 %y, 0
  %z = or i1 %xz, %yz
  br i1 %z, label %nope, label %both_zero

%both_zero:
  call void @foo(i1 %xz)
  call void @foo(i1 %yz)
  call void @bar(i32 %x)
  call void @bar(i32 %y)
  ret void

%nope:
  call void @foo(i1 %z)
  ret void
}
=>
define void @test3_or(i32 %x, i32 %y) {
%0:
  %xz = icmp ne i32 %x, 0
  %yz = icmp ne i32 %y, 0
  %z = or i1 %xz, %yz
  br i1 %z, label %nope, label %both_zero

%both_zero:
  call void @foo(i1 0)
  call void @foo(i1 0)
  call void @bar(i32 0)
  call void @bar(i32 0)
  ret void

%nope:
  call void @foo(i1 1)
  ret void
}
Transformation seems to be correct!


----------------------------------------
define void @test3_or_select(i32 %x, i32 %y) {
%0:
  %xz = icmp ne i32 %x, 0
  %yz = icmp ne i32 %y, 0
  %z = select i1 %xz, i1 1, i1 %yz
  br i1 %z, label %nope, label %both_zero

%both_zero:
  call void @foo(i1 %xz)
  call void @foo(i1 %yz)
  call void @bar(i32 %x)
  call void @bar(i32 %y)
  ret void

%nope:
  call void @foo(i1 %z)
  ret void
}
=>
define void @test3_or_select(i32 %x, i32 %y) {
%0:
  %xz = icmp ne i32 %x, 0
  %yz = icmp ne i32 %y, 0
  %z = select i1 %xz, i1 1, i1 %yz
  br i1 %z, label %nope, label %both_zero

%both_zero:
  call void @foo(i1 0)
  call void @foo(i1 0)
  call void @bar(i32 0)
  call void @bar(i32 0)
  ret void

%nope:
  call void @foo(i1 1)
  ret void
}
Transformation seems to be correct!


----------------------------------------
define void @test4(i1 %b, i32 %x) {
%0:
  br i1 %b, label %sw, label %case3

%sw:
  switch i32 %x, label %default [
    i32 0, label %case0
    i32 1, label %case1
    i32 2, label %case0
    i32 3, label %case3
    i32 4, label %default
  ]

%case0:
  call void @bar(i32 %x)
  ret void

%default:
  call void @bar(i32 %x)
  ret void

%case1:
  call void @bar(i32 %x)
  ret void

%case3:
  call void @bar(i32 %x)
  ret void
}
=>
define void @test4(i1 %b, i32 %x) {
%0:
  br i1 %b, label %sw, label %case3

%sw:
  switch i32 %x, label %default [
    i32 0, label %case0
    i32 1, label %case1
    i32 2, label %case0
    i32 3, label %case3
    i32 4, label %default
  ]

%case0:
  call void @bar(i32 %x)
  ret void

%default:
  call void @bar(i32 %x)
  ret void

%case1:
  call void @bar(i32 1)
  ret void

%case3:
  call void @bar(i32 %x)
  ret void
}
Transformation seems to be correct!


----------------------------------------
define i1 @test5(i32 %x, i32 %y) {
%0:
  %cmp = icmp eq i32 %x, %y
  br i1 %cmp, label %same, label %different

%different:
  %cmp3 = icmp eq i32 %x, %y
  ret i1 %cmp3

%same:
  %cmp2 = icmp ne i32 %x, %y
  ret i1 %cmp2
}
=>
define i1 @test5(i32 %x, i32 %y) {
%0:
  %cmp = icmp eq i32 %x, %y
  br i1 %cmp, label %same, label %different

%different:
  ret i1 0

%same:
  ret i1 0
}
Transformation seems to be correct!


----------------------------------------
define i1 @test6(i32 %x, i32 %y) {
%0:
  %cmp2 = icmp ne i32 %x, %y
  %cmp = icmp eq i32 %x, %y
  %cmp3 = icmp eq i32 %x, %y
  br i1 %cmp, label %same, label %different

%different:
  ret i1 %cmp3

%same:
  ret i1 %cmp2
}
=>
define i1 @test6(i32 %x, i32 %y) {
%0:
  %cmp = icmp eq i32 %x, %y
  br i1 %cmp, label %same, label %different

%different:
  ret i1 0

%same:
  ret i1 0
}
Transformation seems to be correct!


----------------------------------------
define i1 @test6_fp(float %x, float %y) {
%0:
  %cmp2 = fcmp une float %x, %y
  %cmp = fcmp oeq float %x, %y
  %cmp3 = fcmp oeq float %x, %y
  br i1 %cmp, label %same, label %different

%different:
  ret i1 %cmp3

%same:
  ret i1 %cmp2
}
=>
define i1 @test6_fp(float %x, float %y) {
%0:
  %cmp2 = fcmp une float %x, %y
  %cmp = fcmp oeq float %x, %y
  br i1 %cmp, label %same, label %different

%different:
  ret i1 0

%same:
  ret i1 0
}
Transformation seems to be correct!


----------------------------------------
define i1 @test7(i32 %x, i32 %y) {
%0:
  %cmp = icmp sgt i32 %x, %y
  br i1 %cmp, label %same, label %different

%different:
  %cmp3 = icmp sgt i32 %x, %y
  ret i1 %cmp3

%same:
  %cmp2 = icmp sle i32 %x, %y
  ret i1 %cmp2
}
=>
define i1 @test7(i32 %x, i32 %y) {
%0:
  %cmp = icmp sgt i32 %x, %y
  br i1 %cmp, label %same, label %different

%different:
  ret i1 0

%same:
  ret i1 0
}
Transformation seems to be correct!


----------------------------------------
define i1 @test7_fp(float %x, float %y) {
%0:
  %cmp = fcmp ogt float %x, %y
  br i1 %cmp, label %same, label %different

%different:
  %cmp3 = fcmp ogt float %x, %y
  ret i1 %cmp3

%same:
  %cmp2 = fcmp ule float %x, %y
  ret i1 %cmp2
}
=>
define i1 @test7_fp(float %x, float %y) {
%0:
  %cmp = fcmp ogt float %x, %y
  br i1 %cmp, label %same, label %different

%different:
  ret i1 0

%same:
  ret i1 0
}
Transformation seems to be correct!


----------------------------------------
define i1 @test8(i32 %x, i32 %y) {
%0:
  %cmp2 = icmp sle i32 %x, %y
  %cmp = icmp sgt i32 %x, %y
  %cmp3 = icmp sgt i32 %x, %y
  br i1 %cmp, label %same, label %different

%different:
  ret i1 %cmp3

%same:
  ret i1 %cmp2
}
=>
define i1 @test8(i32 %x, i32 %y) {
%0:
  %cmp = icmp sgt i32 %x, %y
  br i1 %cmp, label %same, label %different

%different:
  ret i1 0

%same:
  ret i1 0
}
Transformation seems to be correct!


----------------------------------------
define i1 @test8_fp(float %x, float %y) {
%0:
  %cmp2 = fcmp ule float %x, %y
  %cmp = fcmp ogt float %x, %y
  %cmp3 = fcmp ogt float %x, %y
  br i1 %cmp, label %same, label %different

%different:
  ret i1 %cmp3

%same:
  ret i1 %cmp2
}
=>
define i1 @test8_fp(float %x, float %y) {
%0:
  %cmp2 = fcmp ule float %x, %y
  %cmp = fcmp ogt float %x, %y
  br i1 %cmp, label %same, label %different

%different:
  ret i1 0

%same:
  ret i1 0
}
Transformation seems to be correct!


----------------------------------------
define i32 @test9(i32 %i, i32 %j) {
%0:
  %cmp = icmp eq i32 %i, %j
  br i1 %cmp, label %cond_true, label %ret

%ret:
  ret i32 5

%cond_true:
  %diff = sub i32 %i, %j
  ret i32 %diff
}
=>
define i32 @test9(i32 %i, i32 %j) {
%0:
  %cmp = icmp eq i32 %i, %j
  br i1 %cmp, label %cond_true, label %ret

%ret:
  ret i32 5

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


----------------------------------------
define i32 @test10(i32 %j, i32 %i) {
%0:
  %cmp = icmp eq i32 %i, %j
  br i1 %cmp, label %cond_true, label %ret

%ret:
  ret i32 5

%cond_true:
  %diff = sub i32 %i, %j
  ret i32 %diff
}
=>
define i32 @test10(i32 %j, i32 %i) {
%0:
  %cmp = icmp eq i32 %i, %j
  br i1 %cmp, label %cond_true, label %ret

%ret:
  ret i32 5

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


----------------------------------------
define i32 @test11(i32 %x) {
%0:
  %v0 = call i32 @yogibar()
  %v1 = call i32 @yogibar()
  %cmp = icmp eq i32 %v0, %v1
  br i1 %cmp, label %cond_true, label %next

%next:
  %cmp2 = icmp eq i32 %x, %v0
  br i1 %cmp2, label %cond_true2, label %next2

%cond_true2:
  ret i32 %v0

%next2:
  ret i32 0

%cond_true:
  ret i32 %v1
}
=>
define i32 @test11(i32 %x) {
%0:
  %v0 = call i32 @yogibar()
  %v1 = call i32 @yogibar()
  %cmp = icmp eq i32 %v0, %v1
  br i1 %cmp, label %cond_true, label %next

%next:
  %cmp2 = icmp eq i32 %x, %v0
  br i1 %cmp2, label %cond_true2, label %next2

%cond_true2:
  ret i32 %x

%next2:
  ret i32 0

%cond_true:
  ret i32 %v0
}
Transformation seems to be correct!


----------------------------------------
define i32 @test12(i32 %x) {
%0:
  %cmp = icmp eq i32 %x, 0
  br i1 %cmp, label %cond_true, label %cond_false

%cond_false:
  br label %ret

%cond_true:
  br label %ret

%ret:
  %res = phi i32 [ %x, %cond_true ], [ %x, %cond_false ]
  ret i32 %res
}
=>
define i32 @test12(i32 %x) {
%0:
  %cmp = icmp eq i32 %x, 0
  br i1 %cmp, label %cond_true, label %cond_false

%cond_false:
  br label %ret

%cond_true:
  br label %ret

%ret:
  %res = phi i32 [ 0, %cond_true ], [ %x, %cond_false ]
  ret i32 %res
}
Transformation seems to be correct!


----------------------------------------
define i32 @test13(ptr %ptr1, ptr %ptr2) {
%entry:
  %gep1 = gep ptr %ptr2, 4 x i32 1
  %gep2 = gep ptr %ptr2, 4 x i32 2
  %cmp = icmp eq ptr %ptr1, %ptr2
  br i1 %cmp, label %if, label %end

%if:
  %val1 = load i32, ptr %gep2, align 4
  br label %end

%end:
  %phi1 = phi ptr [ %ptr1, %if ], [ %gep1, %entry ]
  %phi2 = phi i32 [ %val1, %if ], [ 0, %entry ]
  store i32 0, ptr %phi1, align 4
  %val2 = load i32, ptr %gep2, align 4
  %ret = add i32 %phi2, %val2
  ret i32 %ret
}
=>
define i32 @test13(ptr %ptr1, ptr %ptr2) {
%entry:
  %gep1 = gep ptr %ptr2, 4 x i32 1
  %gep2 = gep ptr %ptr2, 4 x i32 2
  %cmp = icmp eq ptr %ptr1, %ptr2
  br i1 %cmp, label %if, label %entry.end_crit_edge

%entry.end_crit_edge:
  %val2.pre = load i32, ptr %gep2, align 4
  br label %end

%if:
  %val1 = load i32, ptr %gep2, align 4
  br label %end

%end:
  %val2 = phi i32 [ %val1, %if ], [ %val2.pre, %entry.end_crit_edge ]
  %phi1 = phi ptr [ %ptr2, %if ], [ %gep1, %entry.end_crit_edge ]
  %phi2 = phi i32 [ %val1, %if ], [ 0, %entry.end_crit_edge ]
  store i32 0, ptr %phi1, align 4
  %ret = add i32 %phi2, %val2
  ret i32 %ret
}
Transformation doesn't verify!
ERROR: Source is more defined than target

Example:
ptr %ptr1 = pointer(non-local, block_id=1, offset=62)
ptr %ptr2 = pointer(non-local, block_id=2, offset=-4)

Source:
ptr %gep1 = pointer(non-local, block_id=2, offset=0)
ptr %gep2 = pointer(non-local, block_id=2, offset=4)
i1 %cmp = #x1 (1)
  >> Jump to %if
i32 %val1 = poison
  >> Jump to %end
ptr %phi1 = pointer(non-local, block_id=1, offset=62)
i32 %phi2 = poison
i32 %val2 = poison
i32 %ret = poison

SOURCE MEMORY STATE
===================
NON-LOCAL BLOCKS:
Block 0 >	size: 0	align: 4	alloc type: 0	address: 0
Block 1 >	size: 66	align: 17179869184	alloc type: 0	address: 6
Block 2 >	size: 129	align: 65536	alloc type: 0	address: 72

Target:
ptr %gep1 = pointer(non-local, block_id=2, offset=0)
ptr %gep2 = pointer(non-local, block_id=2, offset=4)
i1 %cmp = #x1 (1)
  >> Jump to %if
i32 %val1 = poison
  >> Jump to %end
i32 %val2 = poison
ptr %phi1 = pointer(non-local, block_id=2, offset=-4)
i32 %phi2 = poison
void = UB triggered!



------------------- SMT STATS -------------------
Num queries: 91
Num invalid: 0
Num skips:   0
Num trivial: 83 (47.7%)
Num timeout: 0 (0.0%)
Num errors:  0 (0.0%)
Num SAT:     62 (68.1%)
Num UNSAT:   29 (31.9%)
Alive2: Transform doesn't verify; aborting!

stderr:

+ : 'RUN: at line 2'
+ /home/nlopes/alive2/build/opt-alive.sh -basic-aa -gvn -S
+ /home/nlopes/llvm/build/bin/FileCheck /home/nlopes/llvm/llvm/test/Transforms/GVN/condprop.ll

FileCheck error: '<stdin>' is empty.
FileCheck command line:  /home/nlopes/llvm/build/bin/FileCheck /home/nlopes/llvm/llvm/test/Transforms/GVN/condprop.ll

 

<-- Back