xref: /llvm-project/llvm/test/Transforms/InstCombine/2004-09-20-BadLoadCombine.ll (revision 0676acb6fd8d5e22fde16e6ec977ceac08427ab0)
1; RUN: opt < %s -passes='function(instcombine),function(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
8define i32 @test(i1 %C) {
9        %X = alloca i32         ; <ptr> [#uses=3]
10        %X2 = alloca i32                ; <ptr> [#uses=2]
11        store i32 1, ptr %X
12        store i32 2, ptr %X2
13        %Y = select i1 %C, ptr %X, ptr %X2            ; <ptr> [#uses=1]
14        store i32 3, ptr %X
15        %Z = load i32, ptr %Y               ; <i32> [#uses=1]
16        ret i32 %Z
17}
18
19