Test Failure: Transforms/GVN/condprop.ll

Test source: git

Comments: LLVM bug: incorrect propagation of pointer equality

Log:

Source: <stdin>
-- 1. ModuleToFunctionPassAdaptor
ERROR: Unsupported attribute: noalias
-- 1. PassManager<Function> : Skipping NOP
-- 2. GVNPass

----------------------------------------
@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
}
Transformation seems to be correct! (syntactically equal)

-- 3. GVNPass

----------------------------------------
@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
  br label %bb8

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

bb6:
  %#5 = load i32, ptr @a, align 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!

-- 4. PassManager<Function> : Skipping NOP
-- 5. PassManager<Function> : Skipping NOP
-- 6. GVNPass

----------------------------------------
declare void @foo(i1)
declare void @bar(i32)

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
}
Transformation seems to be correct! (syntactically equal)

-- 7. GVNPass

----------------------------------------
declare void @foo(i1)
declare void @bar(i32)

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
}
=>
declare void @foo(i1)
declare void @bar(i32)

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!

-- 8. PassManager<Function> : Skipping NOP
-- 9. PassManager<Function> : Skipping NOP
-- 10. GVNPass

----------------------------------------
declare void @foo(i1)
declare void @bar(i32)

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
}
Transformation seems to be correct! (syntactically equal)

-- 11. GVNPass

----------------------------------------
declare void @foo(i1)
declare void @bar(i32)

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
}
=>
declare void @foo(i1)
declare void @bar(i32)

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!

-- 12. PassManager<Function> : Skipping NOP
-- 13. PassManager<Function> : Skipping NOP
-- 14. GVNPass

----------------------------------------
declare void @foo(i1)
declare void @bar(i32)

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
}
Transformation seems to be correct! (syntactically equal)

-- 15. GVNPass

----------------------------------------
declare void @foo(i1)
declare void @bar(i32)

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
}
=>
declare void @foo(i1)
declare void @bar(i32)

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!

-- 16. PassManager<Function> : Skipping NOP
-- 17. PassManager<Function> : Skipping NOP
-- 18. GVNPass

----------------------------------------
declare void @foo(i1)
declare void @bar(i32)

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
}
Transformation seems to be correct! (syntactically equal)

-- 19. GVNPass

----------------------------------------
declare void @foo(i1)
declare void @bar(i32)

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
}
=>
declare void @foo(i1)
declare void @bar(i32)

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!

-- 20. PassManager<Function> : Skipping NOP
-- 21. PassManager<Function> : Skipping NOP
-- 22. GVNPass

----------------------------------------
declare void @bar(i32)

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
  ]

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

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

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

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

-- 23. GVNPass

----------------------------------------
declare void @bar(i32)

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
  ]

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

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

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

case3:
  call void @bar(i32 %x)
  ret void
}
=>
declare void @bar(i32)

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
  ]

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

case0:
  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!

-- 24. PassManager<Function> : Skipping NOP
-- 25. PassManager<Function> : Skipping NOP
-- 26. GVNPass

----------------------------------------
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
}
Transformation seems to be correct! (syntactically equal)

-- 27. GVNPass

----------------------------------------
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!

-- 28. PassManager<Function> : Skipping NOP
-- 29. PassManager<Function> : Skipping NOP
-- 30. GVNPass

----------------------------------------
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
}
Transformation seems to be correct! (syntactically equal)

-- 31. GVNPass

----------------------------------------
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!

-- 32. PassManager<Function> : Skipping NOP
-- 33. PassManager<Function> : Skipping NOP
-- 34. GVNPass

----------------------------------------
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
}
Transformation seems to be correct! (syntactically equal)

-- 35. GVNPass

----------------------------------------
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:
  %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!

-- 36. PassManager<Function> : Skipping NOP
-- 37. PassManager<Function> : Skipping NOP
-- 38. GVNPass

----------------------------------------
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
}
Transformation seems to be correct! (syntactically equal)

-- 39. GVNPass

----------------------------------------
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!

-- 40. PassManager<Function> : Skipping NOP
-- 41. PassManager<Function> : Skipping NOP
-- 42. GVNPass

----------------------------------------
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
}
Transformation seems to be correct! (syntactically equal)

-- 43. GVNPass

----------------------------------------
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!

-- 44. PassManager<Function> : Skipping NOP
-- 45. PassManager<Function> : Skipping NOP
-- 46. GVNPass

----------------------------------------
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
}
Transformation seems to be correct! (syntactically equal)

-- 47. GVNPass

----------------------------------------
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!

-- 48. PassManager<Function> : Skipping NOP
-- 49. PassManager<Function> : Skipping NOP
-- 50. GVNPass

----------------------------------------
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
}
Transformation seems to be correct! (syntactically equal)

-- 51. GVNPass

----------------------------------------
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:
  %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!

-- 52. PassManager<Function> : Skipping NOP
-- 53. PassManager<Function> : Skipping NOP
-- 54. GVNPass

----------------------------------------
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
}
Transformation seems to be correct! (syntactically equal)

-- 55. GVNPass

----------------------------------------
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!

-- 56. PassManager<Function> : Skipping NOP
-- 57. PassManager<Function> : Skipping NOP
-- 58. GVNPass

----------------------------------------
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
}
Transformation seems to be correct! (syntactically equal)

-- 59. GVNPass

----------------------------------------
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!

-- 60. PassManager<Function> : Skipping NOP
-- 61. PassManager<Function> : Skipping NOP
-- 62. GVNPass

----------------------------------------
declare i32 @yogibar()

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
}
Transformation seems to be correct! (syntactically equal)

-- 63. GVNPass

----------------------------------------
declare i32 @yogibar()

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
}
=>
declare i32 @yogibar()

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!

-- 64. PassManager<Function> : Skipping NOP
-- 65. PassManager<Function> : Skipping NOP
-- 66. GVNPass

----------------------------------------
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
}
Transformation seems to be correct! (syntactically equal)

-- 67. GVNPass

----------------------------------------
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!

-- 68. PassManager<Function> : Skipping NOP
-- 69. PassManager<Function> : Skipping NOP
-- 70. GVNPass

----------------------------------------
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
}
Transformation seems to be correct! (syntactically equal)

-- 71. GVNPass

----------------------------------------
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
  %val2.pre = load i32, ptr %gep2, align 4
  br i1 %cmp, label %if, label %end

if:
  br label %end

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

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

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

SOURCE MEMORY STATE
===================
NON-LOCAL BLOCKS:
Block 0 >	size: 0	align: 4	alloc type: 0	alive: false	address: 0
Block 1 >	size: 5	align: 1	alloc type: 0	alive: true	address: 4
Block 2 >	size: 9	align: 4	alloc type: 0	alive: true	address: 12

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


Pass: GVNPass
Command line: '/home/nlopes/llvm/build/bin/opt' '-load=/home/nlopes/alive2/build/tv/tv.so' '-load-pass-plugin=/home/nlopes/alive2/build/tv/tv.so' '-tv-exit-on-error' '-passes=gvn' '-S' '-tv-smt-to=20000' '-tv-report-dir=/home/nlopes/alive2/build/logs' '-tv-smt-stats'
Wrote bitcode to: "/home/nlopes/alive2/build/logs/in_230ySVgy_iYAX.bc"


------------------- SMT STATS -------------------
Num queries: 102
Num invalid: 0
Num skips:   0
Num trivial: 83 (44.9%)
Num timeout: 0 (0.0%)
Num errors:  0 (0.0%)
Num SAT:     59 (57.8%)
Num UNSAT:   43 (42.2%)
Alive2: Transform doesn't verify; aborting!

stderr:

RUN: at line 2: /home/nlopes/alive2/build/opt-alive.sh < /bitbucket/nlopes/llvm/llvm/test/Transforms/GVN/condprop.ll -passes=gvn -S | /bitbucket/nlopes/llvm/build/bin/FileCheck /bitbucket/nlopes/llvm/llvm/test/Transforms/GVN/condprop.ll
+ /bitbucket/nlopes/llvm/build/bin/FileCheck /bitbucket/nlopes/llvm/llvm/test/Transforms/GVN/condprop.ll
+ /home/nlopes/alive2/build/opt-alive.sh -passes=gvn -S

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

 

<-- Back