Eliminate a branch in FastBitVector setAndCheck, make it vectorizable.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Oct 2013 20:34:30 +0000 (20:34 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Oct 2013 20:34:30 +0000 (20:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=122229

Patch by Nadav Rotem <nrotem@apple.com> on 2013-10-02
Reviewed by Geoffrey Garen.

The CPU is unlikely to predict the branch in setAndCheck. I changed the code to use conditional instructions.

* wtf/FastBitVector.h:
(WTF::FastBitVector::setAndCheck):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@156792 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WTF/ChangeLog
Source/WTF/wtf/FastBitVector.h

index b2dd6dc9fb79abac4f58ac05a2d3e36d28448377..877e9ca519187bb71a3486c499a29936ceac295f 100644 (file)
@@ -1,3 +1,15 @@
+2013-10-02  Nadav Rotem  <nrotem@apple.com>
+
+        Eliminate a branch in FastBitVector setAndCheck, make it vectorizable.
+        https://bugs.webkit.org/show_bug.cgi?id=122229
+
+        Reviewed by Geoffrey Garen.
+
+        The CPU is unlikely to predict the branch in setAndCheck. I changed the code to use conditional instructions.
+
+        * wtf/FastBitVector.h:
+        (WTF::FastBitVector::setAndCheck):
+
 2013-10-02  Anders Carlsson  <andersca@apple.com>
 
         Remove Qt code from WTF
index dfefb0739a5b4cfc7556fdc79c67b57190b5c960..8c8f3d216b8656f452d8af9f70448af687fb88b3 100644 (file)
@@ -101,10 +101,8 @@ public:
         bool changed = false;
         ASSERT(m_numBits == other.m_numBits);
         for (unsigned i = arrayLength(); i--;) {
-            if (m_array[i] == other.m_array[i])
-                continue;
+            changed |= m_array[i] != other.m_array[i];
             m_array[i] = other.m_array[i];
-            changed = true;
         }
         return changed;
     }