[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()

llvm-svn: 284827
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp
index 880adac..c3329d1 100644
--- a/llvm/lib/Analysis/LazyValueInfo.cpp
+++ b/llvm/lib/Analysis/LazyValueInfo.cpp
@@ -978,12 +978,11 @@
   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));
   }
 }