[llvm-commits] [llvm] r40595 - in /llvm/trunk: lib/Transforms/Scalar/GVN.cpp test/Transforms/GVN/2007-07-30-PredIDom.ll
Chris Lattner
clattner at apple.com
Wed Aug 1 11:52:14 PDT 2007
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
More information about the llvm-commits
mailing list