1; RUN: opt -mem2reg < %s -S | FileCheck %s 2; RUN: opt -passes=mem2reg < %s -S | FileCheck %s 3 4declare i32 @def(i32) 5declare i1 @use(i32) 6 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. 10define void @test1() { 11; CHECK-LABEL: @test1( 12 entry: 13 %t = alloca i32 14 br label %loop 15 16 loop: 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) 22 store i32 %n, i32* %t 23 br i1 %c, label %loop, label %exit 24 25 exit: 26 ret void 27} 28 29; Same as above, except there is no following store. The alloca should just be 30; replaced with an undef 31define void @test2() { 32; CHECK-LABEL: @test2( 33 entry: 34 %t = alloca i32 35 br label %loop 36 37 loop: 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 42 43 exit: 44 ret void 45} 46