1 ; Test that pure functions are cse'd away
2 ; RUN: llvm-as < %s | opt -globalsmodref-aa -gvn -instcombine | \
3 ; RUN: llvm-dis | not grep sub
5 define i32 @pure(i32 %X) {
6 %Y = add i32 %X, 1 ; <i32> [#uses=1]
10 define i32 @test1(i32 %X) {
11 %A = call i32 @pure( i32 %X ) ; <i32> [#uses=1]
12 %B = call i32 @pure( i32 %X ) ; <i32> [#uses=1]
13 %C = sub i32 %A, %B ; <i32> [#uses=1]
17 define i32 @test2(i32 %X, i32* %P) {
18 %A = call i32 @pure( i32 %X ) ; <i32> [#uses=1]
19 store i32 %X, i32* %P ;; Does not invalidate 'pure' call.
20 %B = call i32 @pure( i32 %X ) ; <i32> [#uses=1]
21 %C = sub i32 %A, %B ; <i32> [#uses=1]