• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -instcombine -S | \
2; RUN:   grep select | not grep 'i32\*'
3
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.
7;
8; Instcombine should propagate the load through the select instructions to
9; allow elimination of the extra stuff by the mem2reg pass.
10
11define void @_Z5test1RiS_(i32* %x, i32* %y) {
12entry:
13        %tmp.1.i = load i32, i32* %y         ; <i32> [#uses=1]
14        %tmp.3.i = load i32, 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, i32* %retval.i            ; <i32> [#uses=1]
18        store i32 %tmp.4, i32* %x
19        ret void
20}
21
22define void @_Z5test2RiS_(i32* %x, i32* %y) {
23entry:
24        %tmp.0 = alloca i32             ; <i32*> [#uses=2]
25        %tmp.2 = load i32, i32* %x           ; <i32> [#uses=2]
26        store i32 %tmp.2, i32* %tmp.0
27        %tmp.3.i = load i32, 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, i32* %retval.i            ; <i32> [#uses=1]
31        store i32 %tmp.6, i32* %y
32        ret void
33}
34
35