summaryrefslogtreecommitdiffstats
path: root/test/Transforms/SimplifyCFG/duplicate-phis.ll
blob: 4788406fc0f3e7f5120dc35d9cbe1767a7cec22f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
; RUN: opt < %s -instcombine -simplifycfg -S | grep " = phi " | count 1

; instcombine should sort the PHI operands so that simplifycfg can see the
; duplicate and remove it.

define i32 @foo(i1 %t) {
entry:
  call void @bar()
  br i1 %t, label %true, label %false
true:
  call void @bar()
  br label %false
false:
  %a = phi i32 [ 2, %true ], [ 5, %entry ]
  %b = phi i32 [ 5, %entry ], [ 2, %true ]
  call void @bar()
  %c = add i32 %a, %b
  ret i32 %c
}

declare void @bar()