[webkit-changes] [WebKit/WebKit] 3f2afe: [JSC] Add strength reduction for SIMD Vector logic...

Yusuke Suzuki noreply at github.com
Fri Jan 27 16:34:41 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 3f2afe08ec3b95cfc159ff1770687130f3dcbe07
      https://github.com/WebKit/WebKit/commit/3f2afe08ec3b95cfc159ff1770687130f3dcbe07
  Author: Yusuke Suzuki <ysuzuki at apple.com>
  Date:   2023-01-27 (Fri, 27 Jan 2023)

  Changed paths:
    M Source/JavaScriptCore/b3/B3Const128Value.cpp
    M Source/JavaScriptCore/b3/B3Const128Value.h
    M Source/JavaScriptCore/b3/B3ReduceStrength.cpp
    M Source/JavaScriptCore/b3/B3Value.cpp
    M Source/JavaScriptCore/b3/B3Value.h
    M Source/JavaScriptCore/b3/B3ValueInlines.h
    M Source/JavaScriptCore/b3/testb3.h
    M Source/JavaScriptCore/b3/testb3_1.cpp
    M Source/JavaScriptCore/b3/testb3_7.cpp
    M Source/JavaScriptCore/jit/SIMDInfo.h
    M Source/JavaScriptCore/jit/SIMDShuffle.h

  Log Message:
  -----------
  [JSC] Add strength reduction for SIMD Vector logic operations
https://bugs.webkit.org/show_bug.cgi?id=251284
rdar://104754015

Reviewed by Keith Miller.

On x64, we generate B3 nodes for wasm i8x16.shuffle

    @lhs = VectorSwizzle(@input0, @constantMask0)
    @rhs = VectorSwizzle(@input1, @constantMask1)
    @result = VectorOr(@lhs, @rhs)

We found that the hottest function in tfjs is using only one side of operand on shuffle.
This is because wasm i8x16.shuffle always takes 2 operands, and actual use of tfjs is only needing one operand.
As a result, one of the above constantMask becomes all 0xff on x64. And the resulted one is,

    @lhs = VectorSwizzle(@input0, @constantMask0)
    @rhs = VectorSwizzle(@input1, 0xffff_ffff_ffff_ffff_ffff_ffff_ffff_ffff) # It is always 0
    @result = VectorOr(@lhs, @rhs)

This should be converted to

    @result = VectorSwizzle(@input0, @constantMask0)

because (1) @rhs is always all-zeros and (2) we should optimize VectorOr(@lhs, all-zeros) to @lhs.

This patch adds

1. Bit logic strength reduction for VectorOr, VectorAnd, and VectorXor.
2. Add strength reduction for VectorSwizzle when the mask is all OOB.

This imporoves JetStream3/tfjs by 10% on x64 device.

* Source/JavaScriptCore/b3/B3Const128Value.cpp:
(JSC::B3::Const128Value::vectorAndConstant const):
(JSC::B3::Const128Value::vectorOrConstant const):
(JSC::B3::Const128Value::vectorXorConstant const):
* Source/JavaScriptCore/b3/B3Const128Value.h:
* Source/JavaScriptCore/b3/B3ReduceStrength.cpp:
* Source/JavaScriptCore/b3/B3Value.cpp:
(JSC::B3::Value::vectorAndConstant const):
(JSC::B3::Value::vectorOrConstant const):
(JSC::B3::Value::vectorXorConstant const):
* Source/JavaScriptCore/b3/B3Value.h:
* Source/JavaScriptCore/b3/B3ValueInlines.h:
(JSC::B3::Value::isV128 const):
* Source/JavaScriptCore/jit/SIMDInfo.h:
(JSC::vectorAllOnes):
(JSC::vectorAllZeros):
(JSC::vectorOr):
(JSC::vectorAnd):
(JSC::vectorXor):
* Source/JavaScriptCore/jit/SIMDShuffle.h:
(JSC::SIMDShuffle::isAllOutOfBoundsForUnaryShuffle):
(JSC::SIMDShuffle::isAllOutOfBoundsForBinaryShuffle):

Canonical link: https://commits.webkit.org/259514@main




More information about the webkit-changes mailing list