• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -S -basicaa -licm %s | FileCheck %s
2; RUN: opt -aa-pipeline=basic-aa -passes='require<aa>,require<targetir>,require<scalar-evolution>,loop(licm)' < %s -S | FileCheck %s
3declare i32 @foo() readonly argmemonly nounwind
4declare i32 @foo2() readonly nounwind
5declare i32 @bar(i32* %loc2) readonly argmemonly nounwind
6
7define void @test(i32* %loc) {
8; CHECK-LABEL: @test
9; CHECK: @foo
10; CHECK-LABEL: loop:
11  br label %loop
12
13loop:
14  %res = call i32 @foo()
15  store i32 %res, i32* %loc
16  br label %loop
17}
18
19; Negative test: show argmemonly is required
20define void @test_neg(i32* %loc) {
21; CHECK-LABEL: @test_neg
22; CHECK-LABEL: loop:
23; CHECK: @foo
24  br label %loop
25
26loop:
27  %res = call i32 @foo2()
28  store i32 %res, i32* %loc
29  br label %loop
30}
31
32define void @test2(i32* noalias %loc, i32* noalias %loc2) {
33; CHECK-LABEL: @test2
34; CHECK: @bar
35; CHECK-LABEL: loop:
36  br label %loop
37
38loop:
39  %res = call i32 @bar(i32* %loc2)
40  store i32 %res, i32* %loc
41  br label %loop
42}
43
44; Negative test: %might clobber gep
45define void @test3(i32* %loc) {
46; CHECK-LABEL: @test3
47; CHECK-LABEL: loop:
48; CHECK: @bar
49  br label %loop
50
51loop:
52  %res = call i32 @bar(i32* %loc)
53  %gep = getelementptr i32, i32 *%loc, i64 1000000
54  store i32 %res, i32* %gep
55  br label %loop
56}
57
58
59; Negative test: %loc might alias %loc2
60define void @test4(i32* %loc, i32* %loc2) {
61; CHECK-LABEL: @test4
62; CHECK-LABEL: loop:
63; CHECK: @bar
64  br label %loop
65
66loop:
67  %res = call i32 @bar(i32* %loc2)
68  store i32 %res, i32* %loc
69  br label %loop
70}
71