[webkit-changes] [WebKit/WebKit] da65f1: [JSC] Introduce VectorMulByElement

Yusuke Suzuki noreply at github.com
Mon Feb 13 21:03:25 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: da65f1c74056973e16c01c79dbf84e844e1811a8
      https://github.com/WebKit/WebKit/commit/da65f1c74056973e16c01c79dbf84e844e1811a8
  Author: Yusuke Suzuki <ysuzuki at apple.com>
  Date:   2023-02-13 (Mon, 13 Feb 2023)

  Changed paths:
    M Source/JavaScriptCore/assembler/ARM64Assembler.h
    M Source/JavaScriptCore/assembler/MacroAssemblerARM64.h
    M Source/JavaScriptCore/b3/B3LowerToAir.cpp
    M Source/JavaScriptCore/b3/B3Opcode.cpp
    M Source/JavaScriptCore/b3/B3Opcode.h
    M Source/JavaScriptCore/b3/B3ReduceStrength.cpp
    M Source/JavaScriptCore/b3/B3SIMDValue.h
    M Source/JavaScriptCore/b3/B3Validate.cpp
    M Source/JavaScriptCore/b3/B3Value.cpp
    M Source/JavaScriptCore/b3/B3Value.h
    M Source/JavaScriptCore/b3/B3ValueInlines.h
    M Source/JavaScriptCore/b3/B3ValueKey.cpp
    M Source/JavaScriptCore/b3/air/AirOpcode.opcodes
    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

  Log Message:
  -----------
  [JSC] Introduce VectorMulByElement
https://bugs.webkit.org/show_bug.cgi?id=252222
rdar://problem/105428458

Reviewed by Mark Lam.

ARM64 has FMUL by element, which is `fmul.4s v0, v1, v0[0]` for example.
In the above case,

   v0[0] = v1[0] * v0[0]
   v0[1] = v1[1] * v0[0]
   v0[2] = v1[2] * v0[0]
   v0[3] = v1[3] * v0[0]

is done. This is useful since we do not dup-element vector before performing VectorMul.
So, instead of doing,

    VectorMul(@a, VectorDupElement(@b, 0))

we can now convert it to

    VectorMulByElement(@a, @b, 0)

And since (1) now we detect VectorDupElement pattern from VectorSwizzle on ARM64, we can easily do
pattern matching for this case and (2) VectorDupElement is anyway slow (faster than VectorSwizzle,
but still slow instruction). So we can get much faster performance by converting it to VectorMulByElement.

This improves tfjs-wasm-simd by 10%.

* Source/JavaScriptCore/assembler/ARM64Assembler.h:
* Source/JavaScriptCore/assembler/MacroAssemblerARM64.h:
(JSC::MacroAssemblerARM64::vectorMulByElementFloat32):
(JSC::MacroAssemblerARM64::vectorMulByElementFloat64):
* Source/JavaScriptCore/b3/B3LowerToAir.cpp:
* Source/JavaScriptCore/b3/B3Opcode.cpp:
(WTF::printInternal):
* Source/JavaScriptCore/b3/B3Opcode.h:
* Source/JavaScriptCore/b3/B3ReduceStrength.cpp:
* Source/JavaScriptCore/b3/B3SIMDValue.h:
* Source/JavaScriptCore/b3/B3Validate.cpp:
* Source/JavaScriptCore/b3/B3Value.cpp:
(JSC::B3::Value::effects const):
(JSC::B3::Value::key const):
* Source/JavaScriptCore/b3/B3Value.h:
* Source/JavaScriptCore/b3/B3ValueInlines.h:
* Source/JavaScriptCore/b3/B3ValueKey.cpp:
(JSC::B3::ValueKey::materialize const):
* Source/JavaScriptCore/b3/air/AirOpcode.opcodes:
* Source/JavaScriptCore/b3/testb3.h:
* Source/JavaScriptCore/b3/testb3_1.cpp:
(run):
* Source/JavaScriptCore/b3/testb3_7.cpp:
(testVectorFmulByElementFloat):
(testVectorFmulByElementDouble):
* Source/JavaScriptCore/jit/SIMDInfo.h:

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




More information about the webkit-changes mailing list