• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -S -gvn-hoist < %s | FileCheck %s
2; CHECK-LABEL: build_tree
3; CHECK: load
4; CHECK: load
5; Check that the load is not hoisted because the call can potentially
6; modify the global
7
8target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
9
10@heap = external global i32, align 4
11
12define i32 @build_tree() unnamed_addr {
13entry:
14  br label %do.body
15
16do.body:                                          ; preds = %do.body, %entry
17  %tmp9 = load i32, i32* @heap, align 4
18  %cmp = call i1 @pqdownheap(i32 %tmp9)
19  br i1 %cmp, label %do.body, label %do.end
20
21do.end:                                           ; preds = %do.body
22  %tmp20 = load i32, i32* @heap, align 4
23  ret i32 %tmp20
24}
25
26declare i1 @pqdownheap(i32)
27
28@i = external hidden unnamed_addr global i32, align 4
29@j = external hidden unnamed_addr global [573 x i32], align 4
30@v = external global i1
31
32; CHECK-LABEL: test
33; CHECK-LABEL: do.end
34; CHECK: load
35; Check that the load is not hoisted because the call can potentially
36; modify the global
37
38define i32 @test() {
39entry:
40  br label %for.cond
41
42for.cond:
43  %a3 = load volatile i1, i1* @v
44  br i1 %a3, label %for.body, label %while.end
45
46for.body:
47  br label %if.then
48
49if.then:
50  %tmp4 = load i32, i32* @i, align 4
51  br label %for.cond
52
53while.end:
54  br label %do.body
55
56do.body:
57  %tmp9 = load i32, i32* getelementptr inbounds ([573 x i32], [573 x i32]* @j,
58i32 0, i32 1), align 4
59  %tmp10 = load i32, i32* @i, align 4
60  call void @fn()
61  %a1 = load volatile i1, i1* @v
62  br i1 %a1, label %do.body, label %do.end
63
64do.end:
65  %tmp20 = load i32, i32* getelementptr inbounds ([573 x i32], [573 x i32]* @j,
66i32 0, i32 1), align 4
67  ret i32 %tmp20
68}
69
70declare void @fn()
71