1 ; Test that pure functions are cse'd away
2 ; RUN: opt < %s -disable-basicaa -globals-aa -gvn -instcombine -S | FileCheck %s
4 define i32 @pure(i32 %X) {
5 %Y = add i32 %X, 1 ; <i32> [#uses=1]
9 define i32 @test1(i32 %X) {
10 ; CHECK: %A = call i32 @pure(i32 %X)
11 ; CHECK-NEXT: ret i32 0
12 %A = call i32 @pure( i32 %X ) ; <i32> [#uses=1]
13 %B = call i32 @pure( i32 %X ) ; <i32> [#uses=1]
14 %C = sub i32 %A, %B ; <i32> [#uses=1]
18 define i32 @test2(i32 %X, i32* %P) {
19 ; CHECK: %A = call i32 @pure(i32 %X)
20 ; CHECK-NEXT: store i32 %X, i32* %P
21 ; CHECK-NEXT: ret i32 0
22 %A = call i32 @pure( i32 %X ) ; <i32> [#uses=1]
23 store i32 %X, i32* %P ;; Does not invalidate 'pure' call.
24 %B = call i32 @pure( i32 %X ) ; <i32> [#uses=1]
25 %C = sub i32 %A, %B ; <i32> [#uses=1]