1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2 ; RUN: opt -passes=newgvn -S < %s | FileCheck %s
3 @y = external global i32
4 @z = external global i32
6 ; Function Attrs: nounwind ssp uwtable
7 define void @foo(i32 %x) {
8 ; CHECK-LABEL: define void @foo(
9 ; CHECK-SAME: i32 [[X:%.*]]) {
10 ; CHECK-NEXT: [[DOTPRE:%.*]] = load i32, ptr @y, align 4
11 ; CHECK-NEXT: br i1 false, label [[IF_THEN:%.*]], label [[ENTRY_IF_END_CRIT_EDGE:%.*]]
12 ; CHECK: entry.if.end_crit_edge:
13 ; CHECK-NEXT: br label [[IF_END:%.*]]
15 ; CHECK-NEXT: store i8 poison, ptr null, align 1
16 ; CHECK-NEXT: br label [[IF_END]]
18 ; CHECK-NEXT: tail call void @bar(i32 [[DOTPRE]])
19 ; CHECK-NEXT: ret void
23 %.pre = load i32, ptr @y, align 4
24 %cmp = icmp sgt i32 %t, 2
25 br i1 %cmp, label %if.then, label %entry.if.end_crit_edge
27 entry.if.end_crit_edge: ; preds = %entry
30 if.then: ; preds = %entry
31 %add = add nsw i32 %x, 3
32 store i32 %add, ptr @y, align 4
35 if.end: ; preds = %entry.if.end_crit_edge, %if.then
36 %1 = phi i32 [ %.pre, %entry.if.end_crit_edge ], [ %add, %if.then ]
37 tail call void @bar(i32 %1)
41 define void @foo2(i32 %x) {
42 ; CHECK-LABEL: define void @foo2(
43 ; CHECK-SAME: i32 [[X:%.*]]) {
45 ; CHECK-NEXT: [[DOTPRE:%.*]] = load i32, ptr @y, align 4
46 ; CHECK-NEXT: br i1 false, label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
48 ; CHECK-NEXT: store i8 poison, ptr null, align 1
49 ; CHECK-NEXT: br label [[IF_END:%.*]]
51 ; CHECK-NEXT: store i32 1, ptr @z, align 4
52 ; CHECK-NEXT: br label [[IF_END]]
54 ; CHECK-NEXT: tail call void @bar(i32 [[DOTPRE]])
55 ; CHECK-NEXT: ret void
59 %.pre = load i32, ptr @y, align 4
60 %cmp = icmp sgt i32 %t, 2
61 br i1 %cmp, label %if.then, label %if.else
63 if.then: ; preds = %entry
64 %add = add nsw i32 %x, 3
65 store i32 %add, ptr @y, align 4
68 if.else: ; preds = %entry
69 store i32 1, ptr @z, align 4
72 if.end: ; preds = %if.else, %if.then
73 %0 = phi i32 [ %.pre, %if.else ], [ %add, %if.then ]
74 tail call void @bar(i32 %0)
78 declare void @bar(i32)