Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 8eb745ff86d09f8b7853e2a507741fcc6ed332f7
      
https://github.com/WebKit/WebKit/commit/8eb745ff86d09f8b7853e2a507741fcc6ed332f7
  Author: Yusuke Suzuki <[email protected]>
  Date:   2026-03-13 (Fri, 13 Mar 2026)

  Changed paths:
    A JSTests/wasm/stress/simd-canonical-shuffle.js
    A JSTests/wasm/stress/simd-ext-pattern.js
    A JSTests/wasm/stress/simd-shift-left-one.js
    A JSTests/wasm/stress/simd-shuffle-compose.js
    A JSTests/wasm/stress/simd-shuffle-narrowing.js
    A JSTests/wasm/stress/simd-unary-shuffle-canonical.js
    A JSTests/wasm/stress/simd-xor-rotate.js
    M Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
    M Source/JavaScriptCore/Sources.txt
    M Source/JavaScriptCore/assembler/ARM64Assembler.h
    M Source/JavaScriptCore/assembler/CPU.cpp
    M Source/JavaScriptCore/assembler/CPU.h
    M Source/JavaScriptCore/assembler/MacroAssemblerARM64.cpp
    M Source/JavaScriptCore/assembler/MacroAssemblerARM64.h
    M Source/JavaScriptCore/b3/B3Generate.cpp
    M Source/JavaScriptCore/b3/B3LowerToAir.cpp
    M Source/JavaScriptCore/b3/B3Opcode.h
    A Source/JavaScriptCore/b3/B3ReduceSIMDShuffle.cpp
    A Source/JavaScriptCore/b3/B3ReduceSIMDShuffle.h
    M Source/JavaScriptCore/b3/B3ReduceStrength.cpp
    M Source/JavaScriptCore/b3/B3ReduceStrength.h
    M Source/JavaScriptCore/b3/B3SIMDValue.h
    M Source/JavaScriptCore/b3/B3UseCounts.cpp
    M Source/JavaScriptCore/b3/B3UseCounts.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/AirLowerMacros.cpp
    M Source/JavaScriptCore/b3/air/AirOpcode.opcodes
    M Source/JavaScriptCore/b3/air/opcode_generator.rb
    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
    M Source/JavaScriptCore/runtime/OptionsList.h
    M Source/JavaScriptCore/wasm/WasmBBQJIT64.cpp
    M Source/WTF/wtf/PlatformHave.h

  Log Message:
  -----------
  [JSC] Implement SIMD Shuffle reduction
https://bugs.webkit.org/show_bug.cgi?id=309764
rdar://172351912

Reviewed by Keith Miller.

This patch implements recently enabled V8's SIMD shuffle optimization.

1. Add SIMD reductions

ARM64 has zip1, zip2, uzp1, uzp2, trn1, trn2, ext, rev16, rev32, rev64
instructions. And they are more specific shuffling than using tbl
instruction, and it is cheaper than that. We do strength-reduction for
the input to optimize it. However if we do it too early, it makes
analysis of Shuffle hard.
Thus we introduce two passes to B3ReduceStrength. And we do this Vector
shuffle reduction only in the latter pass.

We also add several simple reductions which can be seen in the
JetStream3/argon2-wasm, Vector left-shift to VectorAdd. Using
VectorDupElement.

2. Add B3SIMDShuffleReduction phase

This phase analyzes VectorSwizzle of VectorSwizzle, and attempt to remove
it by reconstructing the pattern for the final output.

3. ARM64 SHA3 XAR lowering

Particular pattern can be converted into ARM64 SHA3-feature's XAR
instruction. We add a lowering rule for that when ARM64 SHA3-feature is
available.

Tests: JSTests/wasm/stress/simd-canonical-shuffle.js
       JSTests/wasm/stress/simd-ext-pattern.js
       JSTests/wasm/stress/simd-shift-left-one.js
       JSTests/wasm/stress/simd-shuffle-compose.js
       JSTests/wasm/stress/simd-shuffle-narrowing.js
       JSTests/wasm/stress/simd-unary-shuffle-canonical.js
       JSTests/wasm/stress/simd-xor-rotate.js
       Source/JavaScriptCore/b3/testb3_1.cpp
       Source/JavaScriptCore/b3/testb3_7.cpp

* JSTests/wasm/stress/simd-canonical-shuffle.js: Added.
(from.string_appeared_here.import.as.assert.from.string_appeared_here.async 
test.const.mem.new.DataView.setI32x4):
(from.string_appeared_here.import.as.assert.from.string_appeared_here.async 
test.getI32x4):
(from.string_appeared_here.import.as.assert.from.string_appeared_here.async 
test.setBytes):
(from.string_appeared_here.import.as.assert.from.string_appeared_here.async 
test.getBytes):
(from.string_appeared_here.import.as.assert.from.string_appeared_here.async 
test.verify):
(from.string_appeared_here.import.as.assert.from.string_appeared_here.async 
test):
* JSTests/wasm/stress/simd-ext-pattern.js: Added.
(from.string_appeared_here.import.as.assert.from.string_appeared_here.async 
test.getResult):
(from.string_appeared_here.import.as.assert.from.string_appeared_here.async 
test):
* JSTests/wasm/stress/simd-shift-left-one.js: Added.
(from.string_appeared_here.import.as.assert.from.string_appeared_here.async 
test):
* JSTests/wasm/stress/simd-shuffle-compose.js: Added.
(from.string_appeared_here.import.as.assert.from.string_appeared_here.async 
test.getResult):
(from.string_appeared_here.import.as.assert.from.string_appeared_here.async 
test):
* JSTests/wasm/stress/simd-shuffle-narrowing.js: Added.
(from.string_appeared_here.import.as.assert.from.string_appeared_here.async 
test):
* JSTests/wasm/stress/simd-unary-shuffle-canonical.js: Added.
(from.string_appeared_here.import.as.assert.from.string_appeared_here.async 
test.getResult32):
(from.string_appeared_here.import.as.assert.from.string_appeared_here.async 
test):
* JSTests/wasm/stress/simd-xor-rotate.js: Added.
(from.string_appeared_here.import.as.assert.from.string_appeared_here.async 
test.rotr64):
(from.string_appeared_here.import.as.assert.from.string_appeared_here.async 
test.let.xor0.0x0123456789ABCDEFn.0xFF00FF00FF00FF00n.let.xor1.0xFEDCBA9876543210n.0x00FF00FF00FF00FFn.verify):
(from.string_appeared_here.import.as.assert.from.string_appeared_here.async 
test):
* Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj:
* Source/JavaScriptCore/Sources.txt:
* Source/JavaScriptCore/assembler/ARM64Assembler.h:
* Source/JavaScriptCore/assembler/CPU.cpp:
(JSC::isARM64_SHA3):
* Source/JavaScriptCore/assembler/CPU.h:
(JSC::isARM64_SHA3):
* Source/JavaScriptCore/assembler/MacroAssemblerARM64.cpp:
(JSC::MacroAssemblerARM64::collectCPUFeatures):
* Source/JavaScriptCore/assembler/MacroAssemblerARM64.h:
(JSC::MacroAssemblerARM64::supportsSHA3):
(JSC::MacroAssemblerARM64::vectorXorRotateRight64):
(JSC::MacroAssemblerARM64::vectorZipLower):
(JSC::MacroAssemblerARM64::vectorZipHigher):
(JSC::MacroAssemblerARM64::vectorUnzipOdd):
(JSC::MacroAssemblerARM64::vectorTransposeEven):
(JSC::MacroAssemblerARM64::vectorTransposeOdd):
(JSC::MacroAssemblerARM64::vectorReverse):
(JSC::MacroAssemblerARM64::vectorZipUpper): Deleted.
* Source/JavaScriptCore/b3/B3Generate.cpp:
(JSC::B3::generateToAir):
* Source/JavaScriptCore/b3/B3LowerToAir.cpp:
* Source/JavaScriptCore/b3/B3Opcode.h:
* Source/JavaScriptCore/b3/B3ReduceSIMDShuffle.cpp: Added.
(JSC::B3::reduceSIMDShuffle):
* Source/JavaScriptCore/b3/B3ReduceSIMDShuffle.h: Copied from 
Source/JavaScriptCore/b3/B3ReduceStrength.h.
* Source/JavaScriptCore/b3/B3ReduceStrength.cpp:
(JSC::B3::reduceStrength):
* Source/JavaScriptCore/b3/B3ReduceStrength.h:
* Source/JavaScriptCore/b3/B3SIMDValue.h:
* Source/JavaScriptCore/b3/B3UseCounts.cpp:
(JSC::B3::UseCountsWithoutUsingInstructions::UseCountsWithoutUsingInstructions):
* Source/JavaScriptCore/b3/B3UseCounts.h:
(JSC::B3::UseCountsWithoutUsingInstructions::numUses const):
* 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/AirLowerMacros.cpp:
(JSC::B3::Air::lowerMacros):
* Source/JavaScriptCore/b3/air/AirOpcode.opcodes:
* Source/JavaScriptCore/b3/air/opcode_generator.rb:
* Source/JavaScriptCore/b3/testb3.h:
* Source/JavaScriptCore/b3/testb3_1.cpp:
(run):
* Source/JavaScriptCore/b3/testb3_7.cpp:
(testVectorXorRotateRight64):
(testVectorUnzipEven):
(testVectorUnzipOdd):
(testVectorZipLower):
(testVectorZipHigher):
(testVectorTransposeEven):
(testVectorTransposeOdd):
(testVectorReverse):
(testVectorShiftByVectorShlByOne):
(testBinarySwizzlePattern):
(testUnarySwizzlePattern):
(testVectorSwizzleToUnzipEven):
(testVectorSwizzleBinaryToUnzipOdd):
(testVectorExtractPair):
(testVectorSwizzleBinaryToEXT):
(testVectorSwizzleUnaryToEXT):
(testVectorSwizzleBinaryCanonical):
(testVectorSwizzleUnaryCanonical):
(testVectorCanonicalSameInputFolding):
(testVectorSwizzleToDupElement):
(testVectorSwizzleComposition):
* Source/JavaScriptCore/jit/SIMDInfo.h:
* Source/JavaScriptCore/jit/SIMDShuffle.h:
(JSC::SIMDShuffle::isI8x16SameElement):
(JSC::SIMDShuffle::isEXTWithSwap):
(JSC::SIMDShuffle::tryMatchCanonicalBinary):
(JSC::SIMDShuffle::tryMatchUnaryAsBinaryCanonical):
(JSC::SIMDShuffle::tryMatchCanonicalUnary):
(JSC::SIMDShuffle::composeShuffle):
(JSC::SIMDShuffle::tryMatchCanonicalBinaryImpl):
* Source/JavaScriptCore/runtime/OptionsList.h:
* Source/JavaScriptCore/wasm/WasmBBQJIT64.cpp:
(JSC::Wasm::BBQJITImpl::BBQJIT::addSIMDI_V):
* Source/WTF/wtf/PlatformHave.h:

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to