On Jul 30, 2007, at 9:57 AM, Owen Anderson wrote: > Author: resistor > Date: Mon Jul 30 11:57:08 2007 > New Revision: 40595 > > URL: http://llvm.org/viewvc/llvm-project?rev=40595&view=rev > Log: > Fix a bug caused by indiscriminantly asking for the dominators of a > predecessor. > ====================================================================== > ======== > --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Mon Jul 30 11:57:08 2007 > @@ -723,7 +723,8 @@ > return V = GetValueForBlock(IDom->getBlock(), orig, Phis); > } > > - > + if (std::distance(pred_begin(BB), pred_end(BB)) == 1) > + return V = GetValueForBlock(IDom->getBlock(), orig, Phis); >
FYI, the if condition is O(n) in the number of predecessors, instead of constant time. Instead of using std::distance, just use BB- >getSinglePredecessor() which is constant time. -Chris _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits