mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-29 22:30:33 +00:00
[SimplifyCFG] propagate branch metadata when creating select
llvm-svn: 267624
This commit is contained in:
parent
ce78de67e5
commit
51a5a5649b
@ -1220,7 +1220,7 @@ HoistTerminator:
|
||||
if (!SI)
|
||||
SI = cast<SelectInst>
|
||||
(Builder.CreateSelect(BI->getCondition(), BB1V, BB2V,
|
||||
BB1V->getName() + "." + BB2V->getName()));
|
||||
BB1V->getName() + "." + BB2V->getName(), BI));
|
||||
|
||||
// Make the PHI node use the select for all incoming values for BB1/BB2
|
||||
for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i)
|
||||
|
@ -387,6 +387,31 @@ for.exit:
|
||||
ret void
|
||||
}
|
||||
|
||||
; Don't drop the metadata.
|
||||
|
||||
define i32 @HoistThenElseCodeToIf(i32 %n) {
|
||||
; CHECK-LABEL: @HoistThenElseCodeToIf(
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i32 %n, 0
|
||||
; CHECK-NEXT: [[DOT:%.*]] = select i1 [[TOBOOL]], i32 1, i32 234, !prof !11
|
||||
; CHECK-NEXT: ret i32 [[DOT]]
|
||||
;
|
||||
entry:
|
||||
%tobool = icmp eq i32 %n, 0
|
||||
br i1 %tobool, label %if, label %else, !prof !0
|
||||
|
||||
if:
|
||||
br label %return
|
||||
|
||||
else:
|
||||
br label %return
|
||||
|
||||
return:
|
||||
%retval.0 = phi i32 [ 1, %if ], [ 234, %else ]
|
||||
ret i32 %retval.0
|
||||
}
|
||||
|
||||
|
||||
!0 = !{!"branch_weights", i32 3, i32 5}
|
||||
!1 = !{!"branch_weights", i32 1, i32 1}
|
||||
!2 = !{!"branch_weights", i32 1, i32 2}
|
||||
@ -414,3 +439,5 @@ for.exit:
|
||||
;; The false weight prints out as a negative integer here, but inside llvm, we
|
||||
;; treat the weight as an unsigned integer.
|
||||
; CHECK: !10 = !{!"branch_weights", i32 112017436, i32 -735157296}
|
||||
; CHECK: !11 = !{!"branch_weights", i32 3, i32 5}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user