mirror of
https://github.com/RPCSX/llvm.git
synced 2025-03-01 09:26:22 +00:00
[LVI] Fix a bug with a guard being the very first instruction in a BB not taken into account
While looking for guards use reverse iterator and scan up to rend() not to begin() git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284827 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
73cda08c45
commit
d193fb5457
@ -978,12 +978,11 @@ void LazyValueInfoImpl::intersectAssumeOrGuardBlockValueConstantRange(
|
|||||||
if (!GuardDecl || GuardDecl->use_empty())
|
if (!GuardDecl || GuardDecl->use_empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (BasicBlock::iterator I = BBI->getIterator(),
|
for (Instruction &I : make_range(BBI->getIterator().getReverse(),
|
||||||
E = BBI->getParent()->begin(); I != E; I--) {
|
BBI->getParent()->rend())) {
|
||||||
Value *Cond = nullptr;
|
Value *Cond = nullptr;
|
||||||
if (!match(&*I, m_Intrinsic<Intrinsic::experimental_guard>(m_Value(Cond))))
|
if (match(&I, m_Intrinsic<Intrinsic::experimental_guard>(m_Value(Cond))))
|
||||||
continue;
|
BBLV = intersect(BBLV, getValueFromCondition(Val, Cond));
|
||||||
BBLV = intersect(BBLV, getValueFromCondition(Val, Cond));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,3 +93,20 @@ continue:
|
|||||||
%result = or i1 %dead, %alive
|
%result = or i1 %dead, %alive
|
||||||
ret i1 %result
|
ret i1 %result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
; Check that we handle the case when the guard is the very first instruction in
|
||||||
|
; a basic block.
|
||||||
|
define i1 @test6(i32 %a) {
|
||||||
|
; CHECK-LABEL: @test6(
|
||||||
|
; CHECK: %alive = icmp eq i32 %a, 8
|
||||||
|
; CHECK-NEXT: %result = or i1 false, %alive
|
||||||
|
%cmp = icmp ult i32 %a, 16
|
||||||
|
br label %continue
|
||||||
|
|
||||||
|
continue:
|
||||||
|
call void(i1,...) @llvm.experimental.guard(i1 %cmp) [ "deopt"() ]
|
||||||
|
%dead = icmp eq i32 %a, 16
|
||||||
|
%alive = icmp eq i32 %a, 8
|
||||||
|
%result = or i1 %dead, %alive
|
||||||
|
ret i1 %result
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user