• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; XFAIL: *
2; RUN: opt < %s -basicaa -newgvn -S | FileCheck %s
3
4@a = external global i32		; <i32*> [#uses=7]
5
6;; NewGVN takes two passes to get this, because we prune predicateinfo
7; CHECK-LABEL: @test1(
8define i32 @test1() nounwind {
9entry:
10	%0 = load i32, i32* @a, align 4
11	%1 = icmp eq i32 %0, 4
12	br i1 %1, label %bb, label %bb1
13
14bb:		; preds = %entry
15	br label %bb8
16
17bb1:		; preds = %entry
18	%2 = load i32, i32* @a, align 4
19	%3 = icmp eq i32 %2, 5
20	br i1 %3, label %bb2, label %bb3
21
22bb2:		; preds = %bb1
23	br label %bb8
24
25bb3:		; preds = %bb1
26	%4 = load i32, i32* @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
30
31bb4:		; preds = %bb3
32	%6 = load i32, i32* @a, align 4
33	%7 = add i32 %6, 5
34	br label %bb8
35
36bb5:		; preds = %bb3
37	%8 = load i32, i32* @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
41
42bb6:		; preds = %bb5
43	%10 = load i32, i32* @a, align 4
44	%11 = add i32 %10, 4
45	br label %bb8
46
47bb7:		; preds = %bb5
48	%12 = load i32, i32* @a, align 4
49	br label %bb8
50
51bb8:		; preds = %bb7, %bb6, %bb4, %bb2, %bb
52	%.0 = phi i32 [ %12, %bb7 ], [ %11, %bb6 ], [ %7, %bb4 ], [ 4, %bb2 ], [ 5, %bb ]
53	br label %return
54
55return:		; preds = %bb8
56	ret i32 %.0
57}
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(
62define 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
67
68same:
69; CHECK: ret i1 false
70  ret i1 %cmp2
71
72different:
73; CHECK: ret i1 false
74  ret i1 %cmp3
75}
76
77; CHECK-LABEL: @test6_fp(
78define 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
83
84same:
85; CHECK: ret i1 false
86  ret i1 %cmp2
87
88different:
89; CHECK: ret i1 false
90  ret i1 %cmp3
91}
92; CHECK-LABEL: @test8(
93define 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
98
99same:
100; CHECK: ret i1 false
101  ret i1 %cmp2
102
103different:
104; CHECK: ret i1 false
105  ret i1 %cmp3
106}
107
108; CHECK-LABEL: @test8_fp(
109define 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
114
115same:
116; CHECK: ret i1 false
117  ret i1 %cmp2
118
119different:
120; CHECK: ret i1 false
121  ret i1 %cmp3
122}
123
124