1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -mem2reg < %s -S | FileCheck %s
3 ; RUN: opt -passes=mem2reg < %s -S | FileCheck %s
8 ; Special case of a single-BB alloca does not apply here since the load
9 ; is affected by the following store. Expect this case to be identified
10 ; and a PHI node to be created.
11 define void @test1() {
12 ; CHECK-LABEL: @test1(
14 ; CHECK-NEXT: br label [[LOOP:%.*]]
16 ; CHECK-NEXT: [[T_0:%.*]] = phi i32 [ undef, [[ENTRY:%.*]] ], [ [[N:%.*]], [[LOOP]] ]
17 ; CHECK-NEXT: [[C:%.*]] = call i1 @use(i32 [[T_0]])
18 ; CHECK-NEXT: [[N]] = call i32 @def(i32 7)
19 ; CHECK-NEXT: br i1 [[C]], label [[LOOP]], label [[EXIT:%.*]]
21 ; CHECK-NEXT: ret void
28 %v = load i32, i32* %t
29 %c = call i1 @use(i32 %v)
30 %n = call i32 @def(i32 7)
32 br i1 %c, label %loop, label %exit
38 ; Same as above, except there is no following store. The alloca should just be
39 ; replaced with an undef
40 define void @test2() {
41 ; CHECK-LABEL: @test2(
43 ; CHECK-NEXT: br label [[LOOP:%.*]]
45 ; CHECK-NEXT: [[C:%.*]] = call i1 @use(i32 undef)
46 ; CHECK-NEXT: br i1 [[C]], label [[LOOP]], label [[EXIT:%.*]]
48 ; CHECK-NEXT: ret void
55 %v = load i32, i32* %t
56 %c = call i1 @use(i32 %v)
57 br i1 %c, label %loop, label %exit