aboutsummaryrefslogtreecommitdiff
path: root/llvm/test/Transforms/GVN/PRE/pre-basic-add.ll
blob: 9bf64962ecb1f43e438205fb0da5f409046f5cf1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt < %s -passes=gvn -enable-pre -S | FileCheck %s --check-prefixes=CHECK,MDEP
; RUN: opt < %s -passes='gvn<memoryssa>' -enable-pre -S | FileCheck %s --check-prefixes=CHECK,MSSA
; RUN: opt < %s -passes="gvn<pre>" -enable-pre=false -S | FileCheck %s

@H = common global i32 0		; <ptr> [#uses=2]
@G = common global i32 0		; <ptr> [#uses=1]

define i32 @test() nounwind {
; CHECK-LABEL: define i32 @test(
; CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
; CHECK-NEXT:  [[ENTRY:.*:]]
; CHECK-NEXT:    [[TMP0:%.*]] = load i32, ptr @H, align 4
; CHECK-NEXT:    [[TMP1:%.*]] = call i32 (...) @foo() #[[ATTR0]]
; CHECK-NEXT:    [[TMP2:%.*]] = icmp ne i32 [[TMP1]], 0
; CHECK-NEXT:    br i1 [[TMP2]], label %[[BB:.*]], label %[[ENTRY_BB1_CRIT_EDGE:.*]]
; CHECK:       [[ENTRY_BB1_CRIT_EDGE]]:
; CHECK-NEXT:    [[DOTPRE:%.*]] = add i32 [[TMP0]], 42
; CHECK-NEXT:    br label %[[BB1:.*]]
; CHECK:       [[BB]]:
; CHECK-NEXT:    [[TMP3:%.*]] = add i32 [[TMP0]], 42
; CHECK-NEXT:    store i32 [[TMP3]], ptr @G, align 4
; CHECK-NEXT:    br label %[[BB1]]
; CHECK:       [[BB1]]:
; CHECK-NEXT:    [[DOTPRE_PHI:%.*]] = phi i32 [ [[DOTPRE]], %[[ENTRY_BB1_CRIT_EDGE]] ], [ [[TMP3]], %[[BB]] ]
; CHECK-NEXT:    store i32 [[DOTPRE_PHI]], ptr @H, align 4
; CHECK-NEXT:    ret i32 0
;
entry:
  %0 = load i32, ptr @H, align 4		; <i32> [#uses=2]
  %1 = call i32 (...) @foo() nounwind		; <i32> [#uses=1]
  %2 = icmp ne i32 %1, 0		; <i1> [#uses=1]
  br i1 %2, label %bb, label %bb1

bb:		; preds = %entry
  %3 = add i32 %0, 42		; <i32> [#uses=1]
  store i32 %3, ptr @G, align 4
  br label %bb1

bb1:		; preds = %bb, %entry
  %4 = add i32 %0, 42		; <i32> [#uses=1]
  store i32 %4, ptr @H, align 4
  br label %return


return:		; preds = %bb1
  ret i32 0
}

declare i32 @foo(...)
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
; MDEP: {{.*}}
; MSSA: {{.*}}