[llvm] r284827 - [LVI] Fix a bug with a guard being the very first instruction in a BB not taken into account
Artur Pilipenko via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 21 08:02:21 PDT 2016
Author: apilipenko
Date: Fri Oct 21 10:02:21 2016
New Revision: 284827
URL: http://llvm.org/viewvc/llvm-project?rev=284827&view=rev
Log:
[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()
Modified:
llvm/trunk/lib/Analysis/LazyValueInfo.cpp
llvm/trunk/test/Transforms/CorrelatedValuePropagation/guards.ll
Modified: llvm/trunk/lib/Analysis/LazyValueInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LazyValueInfo.cpp?rev=284827&r1=284826&r2=284827&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/LazyValueInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/LazyValueInfo.cpp Fri Oct 21 10:02:21 2016
@@ -978,12 +978,11 @@ void LazyValueInfoImpl::intersectAssumeO
if (!GuardDecl || GuardDecl->use_empty())
return;
- for (BasicBlock::iterator I = BBI->getIterator(),
- E = BBI->getParent()->begin(); I != E; I--) {
+ for (Instruction &I : make_range(BBI->getIterator().getReverse(),
+ BBI->getParent()->rend())) {
Value *Cond = nullptr;
- if (!match(&*I, m_Intrinsic<Intrinsic::experimental_guard>(m_Value(Cond))))
- continue;
- BBLV = intersect(BBLV, getValueFromCondition(Val, Cond));
+ if (match(&I, m_Intrinsic<Intrinsic::experimental_guard>(m_Value(Cond))))
+ BBLV = intersect(BBLV, getValueFromCondition(Val, Cond));
}
}
Modified: llvm/trunk/test/Transforms/CorrelatedValuePropagation/guards.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/CorrelatedValuePropagation/guards.ll?rev=284827&r1=284826&r2=284827&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/CorrelatedValuePropagation/guards.ll (original)
+++ llvm/trunk/test/Transforms/CorrelatedValuePropagation/guards.ll Fri Oct 21 10:02:21 2016
@@ -93,3 +93,20 @@ continue:
%result = or i1 %dead, %alive
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
+}
More information about the llvm-commits
mailing list