1 ; RUN: opt -mem2reg < %s -S | FileCheck %s
2 ; RUN: opt -passes=mem2reg < %s -S | FileCheck %s
7 ; Special case of a single-BB alloca does not apply here since the load
8 ; is affected by the following store. Expect this case to be identified
9 ; and a PHI node to be created.
10 define void @test1() {
11 ; CHECK-LABEL: @test1(
17 %v = load i32, i32* %t
18 %c = call i1 @use(i32 %v)
19 ; CHECK: [[PHI:%.*]] = phi i32 [ undef, %entry ], [ %n, %loop ]
20 ; CHECK: call i1 @use(i32 [[PHI]])
21 %n = call i32 @def(i32 7)
23 br i1 %c, label %loop, label %exit
29 ; Same as above, except there is no following store. The alloca should just be
30 ; replaced with an undef
31 define void @test2() {
32 ; CHECK-LABEL: @test2(
38 %v = load i32, i32* %t
39 %c = call i1 @use(i32 %v)
40 ; CHECK: %c = call i1 @use(i32 undef)
41 br i1 %c, label %loop, label %exit