2016-03-13 05:09:26 +08:00
|
|
|
; RUN: opt < %s -simplifycfg -S | FileCheck %s
|
2004-04-10 07:50:29 +08:00
|
|
|
|
2016-03-15 04:18:59 +08:00
|
|
|
; Use a select to make this a single BB.
|
|
|
|
; Also, make sure the profile metadata is propagated to the select (PR26636).
|
|
|
|
|
2016-03-13 05:09:26 +08:00
|
|
|
define i32 @FoldTwoEntryPHINode(i1 %C, i32 %V1, i32 %V2, i16 %V3) {
|
2004-04-10 07:50:29 +08:00
|
|
|
entry:
|
2016-03-17 23:30:52 +08:00
|
|
|
br i1 %C, label %then, label %else, !prof !0, !unpredictable !1
|
2016-03-13 05:09:26 +08:00
|
|
|
then:
|
|
|
|
%V4 = or i32 %V2, %V1
|
2004-04-10 07:50:29 +08:00
|
|
|
br label %Cont
|
2016-03-13 05:09:26 +08:00
|
|
|
else:
|
|
|
|
%V5 = sext i16 %V3 to i32
|
2011-04-30 02:47:25 +08:00
|
|
|
br label %Cont
|
2016-03-13 05:09:26 +08:00
|
|
|
Cont:
|
|
|
|
%V6 = phi i32 [ %V5, %else ], [ %V4, %then ]
|
|
|
|
call i32 @FoldTwoEntryPHINode( i1 false, i32 0, i32 0, i16 0 )
|
2008-03-18 11:45:45 +08:00
|
|
|
ret i32 %V1
|
2016-03-13 05:09:26 +08:00
|
|
|
|
|
|
|
; CHECK-LABEL: @FoldTwoEntryPHINode(
|
|
|
|
; CHECK-NEXT: entry:
|
|
|
|
; CHECK-NEXT: %V5 = sext i16 %V3 to i32
|
|
|
|
; CHECK-NEXT: %V4 = or i32 %V2, %V1
|
2016-03-17 23:30:52 +08:00
|
|
|
; CHECK-NEXT: %V6 = select i1 %C, i32 %V4, i32 %V5, !prof !0, !unpredictable !1
|
2016-03-13 05:09:26 +08:00
|
|
|
; CHECK-NEXT: %0 = call i32 @FoldTwoEntryPHINode(i1 false, i32 0, i32 0, i16 0)
|
|
|
|
; CHECK-NEXT: ret i32 %V1
|
2004-04-10 07:50:29 +08:00
|
|
|
}
|
|
|
|
|
2016-03-15 04:18:59 +08:00
|
|
|
!0 = !{!"branch_weights", i32 3, i32 5}
|
2016-03-17 23:30:52 +08:00
|
|
|
!1 = !{}
|
2016-03-15 04:18:59 +08:00
|
|
|
|
|
|
|
; CHECK: !0 = !{!"branch_weights", i32 3, i32 5}
|
2016-03-17 23:30:52 +08:00
|
|
|
; CHECK: !1 = !{}
|
2016-03-15 04:18:59 +08:00
|
|
|
|