aboutsummaryrefslogtreecommitdiff
path: root/test/Analysis/GlobalsModRef/purecse.ll
blob: 0c95182d46d7616434dc87c13d8425fe34902981 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
; Test that pure functions are cse'd away

; RUN: llvm-upgrade < %s | llvm-as | opt -globalsmodref-aa -load-vn -gcse -instcombine | llvm-dis | not grep sub

int %pure(int %X) {
	%Y = add int %X, 1
	ret int %Y
}

int %test1(int %X) {
	%A = call int %pure(int %X)
	%B = call int %pure(int %X)
	%C = sub int %A, %B
	ret int %C
}

int %test2(int %X, int* %P) {
	%A = call int %pure(int %X)
	store int %X, int* %P          ;; Does not invalidate 'pure' call.
	%B = call int %pure(int %X)
	%C = sub int %A, %B
	ret int %C
}