1; Test that pure functions are cse'd away 2; RUN: opt < %s -disable-basicaa -globals-aa -gvn -instcombine -S | FileCheck %s 3 4define i32 @pure(i32 %X) { 5 %Y = add i32 %X, 1 ; <i32> [#uses=1] 6 ret i32 %Y 7} 8 9define 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] 15 ret i32 %C 16} 17 18define 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] 26 ret i32 %C 27} 28