⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 197445 in webkit


Ignore:
Timestamp:
Mar 1, 2016, 11:53:20 PM (11 years ago)
Author:
benjamin@webkit.org
Message:

[JSC] Simplify ArithMod(ArithMod(x, const1), const2) if const2 >= const1
https://bugs.webkit.org/show_bug.cgi?id=154904

Reviewed by Saam Barati.

The ASM test "ubench" has a "x % 10 % 255".
The second modulo should be eliminated.

This is a 15% improvement on ASMJS' ubench.

  • dfg/DFGStrengthReductionPhase.cpp:

(JSC::DFG::StrengthReductionPhase::handleNode):

  • tests/stress/arith-modulo-twice.js: Added.

(opaqueModuloSmaller):
(opaqueModuloEqual):
(opaqueModuloLarger):
(opaqueModuloSmallerNeg):
(opaqueModuloEqualNeg):
(opaqueModuloLargerNeg):
(opaqueExpectedOther):

Location:
trunk/Source/JavaScriptCore
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r197444 r197445  
     12016-03-01  Benjamin Poulain  <benjamin@webkit.org>
     2
     3        [JSC] Simplify ArithMod(ArithMod(x, const1), const2) if const2 >= const1
     4        https://bugs.webkit.org/show_bug.cgi?id=154904
     5
     6        Reviewed by Saam Barati.
     7
     8        The ASM test "ubench" has a "x % 10 % 255".
     9        The second modulo should be eliminated.
     10
     11        This is a 15% improvement on ASMJS' ubench.
     12
     13        * dfg/DFGStrengthReductionPhase.cpp:
     14        (JSC::DFG::StrengthReductionPhase::handleNode):
     15        * tests/stress/arith-modulo-twice.js: Added.
     16        (opaqueModuloSmaller):
     17        (opaqueModuloEqual):
     18        (opaqueModuloLarger):
     19        (opaqueModuloSmallerNeg):
     20        (opaqueModuloEqualNeg):
     21        (opaqueModuloLargerNeg):
     22        (opaqueExpectedOther):
     23
    1242016-03-01  Ryosuke Niwa  <rniwa@webkit.org>
    225
  • trunk/Source/JavaScriptCore/dfg/DFGStrengthReductionPhase.cpp

    r197370 r197445  
    3737#include "DFGVariableAccessDataDump.h"
    3838#include "JSCInlines.h"
     39#include <cstdlib>
    3940
    4041namespace JSC { namespace DFG {
     
    170171                    m_changed = true;
    171172                }
     173            }
     174            break;
     175
     176        case ArithMod:
     177            // On Integers
     178            // In: ArithMod(ArithMod(x, const1), const2)
     179            // Out: Identity(ArithMod(x, const1))
     180            //     if const1 <= const2.
     181            if (m_node->binaryUseKind() == Int32Use
     182                && m_node->child2()->isInt32Constant()
     183                && m_node->child1()->op() == ArithMod
     184                && m_node->child1()->binaryUseKind() == Int32Use
     185                && m_node->child1()->child2()->isInt32Constant()
     186                && std::abs(m_node->child1()->child2()->asInt32()) <= std::abs(m_node->child2()->asInt32())) {
     187                    convertToIdentityOverChild1();
    172188            }
    173189            break;
Note: See TracChangeset for help on using the changeset viewer.