• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; Test that GCSE uses basicaa to do alias analysis, which is capable of
2; disambiguating some obvious cases.  All loads should be removable in
3; this testcase.
4
5; RUN: opt < %s -basicaa -gvn -instcombine -dce -S | FileCheck %s
6
7@A = global i32 7
8@B = global i32 8
9
10; CHECK:      define i32 @test()
11; CHECK-NEXT:   store i32 123, i32* @B
12; CHECK-NEXT:   ret i32 0
13
14define i32 @test() {
15	%A1 = load i32, i32* @A
16
17	store i32 123, i32* @B  ; Store cannot alias @A
18
19	%A2 = load i32, i32* @A
20	%X = sub i32 %A1, %A2
21	ret i32 %X
22}
23
24; CHECK:      define i32 @test2()
25; CHECK-NEXT:   br label %Loop
26; CHECK:      Loop:
27; CHECK-NEXT:   store i32 0, i32* @B
28; CHECK-NEXT:   br i1 true, label %out, label %Loop
29; CHECK:      out:
30; CHECK-NEXT:   ret i32 0
31
32define i32 @test2() {
33        %A1 = load i32, i32* @A
34        br label %Loop
35Loop:
36        %AP = phi i32 [0, %0], [%X, %Loop]
37        store i32 %AP, i32* @B  ; Store cannot alias @A
38
39        %A2 = load i32, i32* @A
40        %X = sub i32 %A1, %A2
41        %c = icmp eq i32 %X, 0
42        br i1 %c, label %out, label %Loop
43
44out:
45        ret i32 %X
46}
47
48declare void @external()
49
50; CHECK:      define i32 @test3()
51; CHECK-NEXT:   call void @external()
52; CHECK-NEXT:   ret i32 7
53
54define i32 @test3() {
55	%X = alloca i32
56	store i32 7, i32* %X
57	call void @external()
58	%V = load i32, i32* %X
59	ret i32 %V
60}
61
62