File: gcsetest.ll

package info (click to toggle)
llvm-toolchain-11 1%3A11.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 995,808 kB
  • sloc: cpp: 4,767,656; ansic: 760,916; asm: 477,436; python: 170,940; objc: 69,804; lisp: 29,914; sh: 23,855; f90: 18,173; pascal: 7,551; perl: 7,471; ml: 5,603; awk: 3,489; makefile: 2,573; xml: 915; cs: 573; fortran: 503; javascript: 452
file content (61 lines) | stat: -rw-r--r-- 1,339 bytes parent folder | download | duplicates (9)
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
54
55
56
57
58
59
60
61
; Test that GCSE uses basicaa to do alias analysis, which is capable of
; disambiguating some obvious cases.  All loads should be removable in
; this testcase.

; RUN: opt < %s -basic-aa -gvn -instcombine -dce -S | FileCheck %s

@A = global i32 7
@B = global i32 8

; CHECK:      define i32 @test()
; CHECK-NEXT:   store i32 123, i32* @B
; CHECK-NEXT:   ret i32 0

define i32 @test() {
	%A1 = load i32, i32* @A

	store i32 123, i32* @B  ; Store cannot alias @A

	%A2 = load i32, i32* @A
	%X = sub i32 %A1, %A2
	ret i32 %X
}

; CHECK:      define i32 @test2()
; CHECK-NEXT:   br label %Loop
; CHECK:      Loop:
; CHECK-NEXT:   store i32 0, i32* @B
; CHECK-NEXT:   br i1 true, label %out, label %Loop
; CHECK:      out:
; CHECK-NEXT:   ret i32 0

define i32 @test2() {
        %A1 = load i32, i32* @A
        br label %Loop
Loop:
        %AP = phi i32 [0, %0], [%X, %Loop]
        store i32 %AP, i32* @B  ; Store cannot alias @A

        %A2 = load i32, i32* @A
        %X = sub i32 %A1, %A2
        %c = icmp eq i32 %X, 0
        br i1 %c, label %out, label %Loop

out:
        ret i32 %X
}

declare void @external()

; CHECK:      define i32 @test3()
; CHECK-NEXT:   call void @external()
; CHECK-NEXT:   ret i32 7

define i32 @test3() {
	%X = alloca i32
	store i32 7, i32* %X
	call void @external()
	%V = load i32, i32* %X
	ret i32 %V
}