2004-07-27 06:35:11 +00:00
|
|
|
; Test that pure functions are cse'd away
|
|
|
|
|
2006-12-02 04:23:10 +00:00
|
|
|
; RUN: llvm-upgrade < %s | llvm-as | opt -globalsmodref-aa -load-vn -gcse -instcombine | llvm-dis | not grep sub
|
2004-07-27 06:35:11 +00:00
|
|
|
|
|
|
|
int %pure(int %X) {
|
|
|
|
%Y = add int %X, 1
|
|
|
|
ret int %Y
|
|
|
|
}
|
|
|
|
|
2004-12-17 17:14:00 +00:00
|
|
|
int %test1(int %X) {
|
2004-07-27 06:35:11 +00:00
|
|
|
%A = call int %pure(int %X)
|
|
|
|
%B = call int %pure(int %X)
|
|
|
|
%C = sub int %A, %B
|
|
|
|
ret int %C
|
|
|
|
}
|
2004-12-17 17:14:00 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|