1 ; RUN: opt -basic-aa -gvn -S < %s | FileCheck %s
2 @y = external global i32
3 @z = external global i32
5 ; Function Attrs: nounwind ssp uwtable
6 define void @foo(i32 %x) {
8 ; CHECK: %.pre = load i32, i32* @y
9 ; CHECK: call void @bar(i32 %.pre)
12 %.pre = load i32, i32* @y, align 4
13 %cmp = icmp sgt i32 %t, 2
14 br i1 %cmp, label %if.then, label %entry.if.end_crit_edge
16 entry.if.end_crit_edge: ; preds = %entry
19 if.then: ; preds = %entry
20 %add = add nsw i32 %x, 3
21 store i32 %add, i32* @y, align 4
24 if.end: ; preds = %entry.if.end_crit_edge, %if.then
25 %1 = phi i32 [ %.pre, %entry.if.end_crit_edge ], [ %add, %if.then ]
26 tail call void @bar(i32 %1)
30 define void @foo2(i32 %x) {
31 ; CHECK: @foo2(i32 %x)
32 ; CHECK: %.pre = load i32, i32* @y
33 ; CHECK: tail call void @bar(i32 %.pre)
36 %.pre = load i32, i32* @y, align 4
37 %cmp = icmp sgt i32 %t, 2
38 br i1 %cmp, label %if.then, label %if.else
40 if.then: ; preds = %entry
41 %add = add nsw i32 %x, 3
42 store i32 %add, i32* @y, align 4
45 if.else: ; preds = %entry
46 store i32 1, i32* @z, align 4
49 if.end: ; preds = %if.else, %if.then
50 %0 = phi i32 [ %.pre, %if.else ], [ %add, %if.then ]
51 tail call void @bar(i32 %0)
55 declare void @bar(i32)