1 ; RUN: opt < %s -instcombine -S | \
2 ; RUN: grep select | not grep {i32\\*}
4 ; This testcase corresponds to PR362, which notices that this horrible code
5 ; is generated by the C++ front-end and LLVM optimizers, which has lots of
6 ; loads and other stuff that are unneeded.
8 ; Instcombine should propagate the load through the select instructions to
9 ; allow elimination of the extra stuff by the mem2reg pass.
11 define void @_Z5test1RiS_(i32* %x, i32* %y) {
13 %tmp.1.i = load i32* %y ; <i32> [#uses=1]
14 %tmp.3.i = load i32* %x ; <i32> [#uses=1]
15 %tmp.4.i = icmp slt i32 %tmp.1.i, %tmp.3.i ; <i1> [#uses=1]
16 %retval.i = select i1 %tmp.4.i, i32* %y, i32* %x ; <i32*> [#uses=1]
17 %tmp.4 = load i32* %retval.i ; <i32> [#uses=1]
18 store i32 %tmp.4, i32* %x
22 define void @_Z5test2RiS_(i32* %x, i32* %y) {
24 %tmp.0 = alloca i32 ; <i32*> [#uses=2]
25 %tmp.2 = load i32* %x ; <i32> [#uses=2]
26 store i32 %tmp.2, i32* %tmp.0
27 %tmp.3.i = load i32* %y ; <i32> [#uses=1]
28 %tmp.4.i = icmp slt i32 %tmp.2, %tmp.3.i ; <i1> [#uses=1]
29 %retval.i = select i1 %tmp.4.i, i32* %y, i32* %tmp.0 ; <i32*> [#uses=1]
30 %tmp.6 = load i32* %retval.i ; <i32> [#uses=1]
31 store i32 %tmp.6, i32* %y