1 ; RUN: opt < %s -gvn -enable-pre -S | FileCheck %s
3 @H = common global i32 0
4 @G = common global i32 0
6 define i32 @test1(i1 %cond, i32 %v) nounwind {
9 br i1 %cond, label %bb, label %bb1
12 %add.1 = add nuw nsw i32 %v, 42
13 ; CHECK: %add.1 = add i32 %v, 42
14 store i32 %add.1, i32* @G, align 4
18 ; CHECK: %.pre = add i32 %v, 42
22 ; CHECK: %add.2.pre-phi = phi i32 [ %.pre, %bb1 ], [ %add.1, %bb ]
23 ; CHECK-NEXT: store i32 %add.2.pre-phi, i32* @H, align 4
24 ; CHECK-NEXT: ret i32 0
25 %add.2 = add i32 %v, 42
26 store i32 %add.2, i32* @H, align 4
30 define i32 @test2(i1 %cond, i32 %v) nounwind {
33 br i1 %cond, label %bb, label %bb1
36 %add.1 = add i32 %v, 42
37 ; CHECK: %add.1 = add i32 %v, 42
38 store i32 %add.1, i32* @G, align 4
42 ; CHECK: %.pre = add nuw nsw i32 %v, 42
46 ; CHECK: %add.2.pre-phi = phi i32 [ %.pre, %bb1 ], [ %add.1, %bb ]
47 ; CHECK-NEXT: store i32 %add.2.pre-phi, i32* @H, align 4
48 ; CHECK-NEXT: ret i32 0
49 %add.2 = add nuw nsw i32 %v, 42
50 store i32 %add.2, i32* @H, align 4