1 ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep select | not grep 'int\*'
3 ; This testcase corresponds to PR362, which notices that this horrible code
4 ; is generated by the C++ front-end and LLVM optimizers, which has lots of
5 ; loads and other stuff that are unneeded.
7 ; Instcombine should propagate the load through the select instructions to
8 ; allow elimination of the extra stuff by the mem2reg pass.
10 implementation ; Functions:
12 void %_Z5test1RiS_(int* %x, int* %y) {
14 %tmp.1.i = load int* %y ; <int> [#uses=1]
15 %tmp.3.i = load int* %x ; <int> [#uses=1]
16 %tmp.4.i = setlt int %tmp.1.i, %tmp.3.i ; <bool> [#uses=1]
17 %retval.i = select bool %tmp.4.i, int* %y, int* %x ; <int*> [#uses=1]
18 %tmp.4 = load int* %retval.i ; <int> [#uses=1]
19 store int %tmp.4, int* %x
23 void %_Z5test2RiS_(int* %x, int* %y) {
25 %tmp.0 = alloca int ; <int*> [#uses=2]
26 %tmp.2 = load int* %x ; <int> [#uses=2]
27 store int %tmp.2, int* %tmp.0
28 %tmp.3.i = load int* %y ; <int> [#uses=1]
29 %tmp.4.i = setlt int %tmp.2, %tmp.3.i ; <bool> [#uses=1]
30 %retval.i = select bool %tmp.4.i, int* %y, int* %tmp.0 ; <int*> [#uses=1]
31 %tmp.6 = load int* %retval.i ; <int> [#uses=1]
32 store int %tmp.6, int* %y