• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -gvn -enable-pre -S | FileCheck %s
2
3@H = common global i32 0
4@G = common global i32 0
5
6define i32 @test1(i1 %cond, i32 %v) nounwind {
7; CHECK-LABEL: @test1
8entry:
9    br i1 %cond, label %bb, label %bb1
10
11bb:
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
15    br label %return
16
17bb1:
18; CHECK: %.pre = add i32 %v, 42
19    br label %return
20
21return:
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
27    ret i32 0
28}
29
30define i32 @test2(i1 %cond, i32 %v) nounwind {
31; CHECK-LABEL: @test2
32entry:
33    br i1 %cond, label %bb, label %bb1
34
35bb:
36    %add.1 = add i32 %v, 42
37; CHECK: %add.1 = add i32 %v, 42
38    store i32 %add.1, i32* @G, align 4
39    br label %return
40
41bb1:
42; CHECK: %.pre = add nuw nsw i32 %v, 42
43    br label %return
44
45return:
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
51    ret i32 0
52}
53