mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
[CodeGenPrepare] don't convert an unpredictable select into control flow
Suggested in the review of D19488: http://reviews.llvm.org/D19488 llvm-svn: 267504
This commit is contained in:
parent
69d7e17058
commit
b5dda51232
@ -4568,7 +4568,8 @@ bool CodeGenPrepare::optimizeSelectInst(SelectInst *SI) {
|
||||
bool VectorCond = !SI->getCondition()->getType()->isIntegerTy(1);
|
||||
|
||||
// Can we convert the 'select' to CF ?
|
||||
if (DisableSelectToBranch || OptSize || !TLI || VectorCond)
|
||||
if (DisableSelectToBranch || OptSize || !TLI || VectorCond ||
|
||||
SI->getMetadata(LLVMContext::MD_unpredictable))
|
||||
return false;
|
||||
|
||||
TargetLowering::SelectSupportKind SelectKind;
|
||||
|
@ -79,6 +79,25 @@ entry:
|
||||
; CHECK: ret float %sel
|
||||
}
|
||||
|
||||
; But if the select is marked unpredictable, then don't turn it into a branch.
|
||||
|
||||
define float @unpredictable_select(float %a, float %b) {
|
||||
; CHECK-LABEL: @unpredictable_select(
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: [[DIV:%.*]] = fdiv float %a, %b
|
||||
; CHECK-NEXT: [[CMP:%.*]] = fcmp ogt float %a, 1.000000e+00
|
||||
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], float [[DIV]], float 2.000000e+00, !unpredictable !0
|
||||
; CHECK-NEXT: ret float [[SEL]]
|
||||
;
|
||||
entry:
|
||||
%div = fdiv float %a, %b
|
||||
%cmp = fcmp ogt float %a, 1.0
|
||||
%sel = select i1 %cmp, float %div, float 2.0, !unpredictable !0
|
||||
ret float %sel
|
||||
}
|
||||
|
||||
!0 = !{}
|
||||
|
||||
; An 'fadd' is not too expensive, so it's ok to speculate.
|
||||
|
||||
define float @fadd_no_sink(float %a, float %b) {
|
||||
|
Loading…
Reference in New Issue
Block a user