7c95cfd089b4271fb922425eb4f3b2a14d313b66
[oota-llvm.git] / test / Transforms / DeadStoreElimination / ifthenelse2.ll
1 ; RUN: opt < %s -basicaa -dse -S | FileCheck %s
2
3 ; The add and store in entry block should be removed by non-local DSE.
4 ; CHECK-NOT: %stval = add
5 ; CHECK-NOT: store i32 %stval
6 ;
7 ; The stores in if.then and if.else blocks should be removed by non-local DSE.
8 ; CHECK-NOT: store i32 %1
9 ; CHECK-NOT: store i32 %2
10 ;
11 define void @foo(i32* noalias nocapture %a, i32* noalias nocapture readonly %b, i32 %c) {
12 entry:
13   %0 = load i32, i32* %b, align 4
14   %stval = add nsw i32 %0, 1
15   store i32 %stval, i32* %a, align 4
16   %cmp = icmp sgt i32 %c, 0
17   br i1 %cmp, label %if.then, label %if.else
18
19 if.then:
20   %1 = add nsw i32 %c, 10
21   store i32 %1, i32* %a, align 4
22   br label %if.end
23
24 if.else:
25   %2 = add nsw i32 %c, 13
26   store i32 %2, i32* %a, align 4
27   br label %if.end
28
29 if.end:
30   %3 = phi i32 [ %1, %if.then ], [ %2, %if.else ]
31   %4 = sub nsw i32 %3, 6
32   store i32 %4, i32* %a, align 4
33   ret void
34 }