2 ; RUN: opt < %s -passes=newgvn -S | FileCheck %s
4 @a = external global i32 ; <ptr> [#uses=7]
6 ;; NewGVN takes two passes to get this, because we prune predicateinfo
8 define i32 @test1() nounwind {
10 %0 = load i32, ptr @a, align 4
11 %1 = icmp eq i32 %0, 4
12 br i1 %1, label %bb, label %bb1
18 %2 = load i32, ptr @a, align 4
19 %3 = icmp eq i32 %2, 5
20 br i1 %3, label %bb2, label %bb3
26 %4 = load i32, ptr @a, align 4
27 %5 = icmp eq i32 %4, 4
28 ; CHECK: br i1 false, label %bb4, label %bb5
29 br i1 %5, label %bb4, label %bb5
32 %6 = load i32, ptr @a, align 4
37 %8 = load i32, ptr @a, align 4
38 %9 = icmp eq i32 %8, 5
39 ; CHECK: br i1 false, label %bb6, label %bb7
40 br i1 %9, label %bb6, label %bb7
43 %10 = load i32, ptr @a, align 4
48 %12 = load i32, ptr @a, align 4
51 bb8: ; preds = %bb7, %bb6, %bb4, %bb2, %bb
52 %.0 = phi i32 [ %12, %bb7 ], [ %11, %bb6 ], [ %7, %bb4 ], [ 4, %bb2 ], [ 5, %bb ]
55 return: ; preds = %bb8
58 ;; NewGVN takes two passes to get test[6,8] and test[6,8]_fp's main part
59 ;; The icmp ne requires an equality table that inserts the inequalities for each
60 ;; discovered equality while processing.
61 ; CHECK-LABEL: @test6(
62 define i1 @test6(i32 %x, i32 %y) {
63 %cmp2 = icmp ne i32 %x, %y
64 %cmp = icmp eq i32 %x, %y
65 %cmp3 = icmp eq i32 %x, %y
66 br i1 %cmp, label %same, label %different
77 ; CHECK-LABEL: @test6_fp(
78 define i1 @test6_fp(float %x, float %y) {
79 %cmp2 = fcmp une float %x, %y
80 %cmp = fcmp oeq float %x, %y
81 %cmp3 = fcmp oeq float %x, %y
82 br i1 %cmp, label %same, label %different
92 ; CHECK-LABEL: @test8(
93 define i1 @test8(i32 %x, i32 %y) {
94 %cmp2 = icmp sle i32 %x, %y
95 %cmp = icmp sgt i32 %x, %y
96 %cmp3 = icmp sgt i32 %x, %y
97 br i1 %cmp, label %same, label %different
100 ; CHECK: ret i1 false
104 ; CHECK: ret i1 false
108 ; CHECK-LABEL: @test8_fp(
109 define i1 @test8_fp(float %x, float %y) {
110 %cmp2 = fcmp ule float %x, %y
111 %cmp = fcmp ogt float %x, %y
112 %cmp3 = fcmp ogt float %x, %y
113 br i1 %cmp, label %same, label %different
116 ; CHECK: ret i1 false
120 ; CHECK: ret i1 false