[InstCombine] Generalize sub of selects optimization to all BinaryOperators
[oota-llvm.git] / test / Transforms / InstCombine / 2004-09-20-BadLoadCombine.ll
1 ; RUN: opt < %s -instcombine -mem2reg -S | \
2 ; RUN:   not grep "i32 1"
3
4 ; When propagating the load through the select, make sure that the load is
5 ; inserted where the original load was, not where the select is.  Not doing
6 ; so could produce incorrect results!
7
8 define i32 @test(i1 %C) {
9         %X = alloca i32         ; <i32*> [#uses=3]
10         %X2 = alloca i32                ; <i32*> [#uses=2]
11         store i32 1, i32* %X
12         store i32 2, i32* %X2
13         %Y = select i1 %C, i32* %X, i32* %X2            ; <i32*> [#uses=1]
14         store i32 3, i32* %X
15         %Z = load i32, i32* %Y               ; <i32> [#uses=1]
16         ret i32 %Z
17 }
18