llvm.org GIT mirror llvm / d193fb5
[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 Artur Pilipenko 3 years ago
2 changed file(s) with 21 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
977977 if (!GuardDecl || GuardDecl->use_empty())
978978 return;
979979
980 for (BasicBlock::iterator I = BBI->getIterator(),
981 E = BBI->getParent()->begin(); I != E; I--) {
980 for (Instruction &I : make_range(BBI->getIterator().getReverse(),
981 BBI->getParent()->rend())) {
982982 Value *Cond = nullptr;
983 if (!match(&*I, m_Intrinsic(m_Value(Cond))))
984 continue;
985 BBLV = intersect(BBLV, getValueFromCondition(Val, Cond));
983 if (match(&I, m_Intrinsic(m_Value(Cond))))
984 BBLV = intersect(BBLV, getValueFromCondition(Val, Cond));
986985 }
987986 }
988987
9292 %result = or i1 %dead, %alive
9393 ret i1 %result
9494 }
95
96 ; Check that we handle the case when the guard is the very first instruction in
97 ; a basic block.
98 define i1 @test6(i32 %a) {
99 ; CHECK-LABEL: @test6(
100 ; CHECK: %alive = icmp eq i32 %a, 8
101 ; CHECK-NEXT: %result = or i1 false, %alive
102 %cmp = icmp ult i32 %a, 16
103 br label %continue
104
105 continue:
106 call void(i1,...) @llvm.experimental.guard(i1 %cmp) [ "deopt"() ]
107 %dead = icmp eq i32 %a, 16
108 %alive = icmp eq i32 %a, 8
109 %result = or i1 %dead, %alive
110 ret i1 %result
111 }