From 14c000936e00c7cb910742536d294875b00d350e Mon Sep 17 00:00:00 2001 From: Daniel Berlin Date: Mon, 25 Jul 2016 17:36:14 +0000 Subject: [PATCH] NFC: Make a few asserts in GVNHoist do the same thing, but cheaper. llvm-svn: 276662 --- llvm/lib/Transforms/Scalar/GVNHoist.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/llvm/lib/Transforms/Scalar/GVNHoist.cpp b/llvm/lib/Transforms/Scalar/GVNHoist.cpp index 96cd3fc..e12644a 100644 --- a/llvm/lib/Transforms/Scalar/GVNHoist.cpp +++ b/llvm/lib/Transforms/Scalar/GVNHoist.cpp @@ -74,8 +74,10 @@ public: if (NA < NB) return true; if (NA == NB) { - assert (DFSNumber.count(A) && DFSNumber.count(B)); - return DFSNumber[A] < DFSNumber[B]; + unsigned ADFS = DFSNumber.lookup(A); + unsigned BDFS = DFSNumber.lookup(B); + assert (ADFS && ADFS); + return ADFS < BDFS; } return false; } @@ -295,8 +297,10 @@ private: /* Return true when I1 appears before I2 in the instructions of BB. */ bool firstInBB(const Instruction *I1, const Instruction *I2) { assert (I1->getParent() == I2->getParent()); - assert (DFSNumber.count(I1) && DFSNumber.count(I2)); - return DFSNumber[I1] < DFSNumber[I2]; + unsigned I1DFS = DFSNumber.lookup(I1); + unsigned I2DFS = DFSNumber.lookup(I2); + assert (I1DFS && I2DFS); + return I1DFS < I2DFS; } // Return true when there are users of Def in BB. -- 2.7.4