Repository navigation
Commit 8eb745f
committed
[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@main1 parent 372cd42 commit 8eb745f
40 files changed
Lines changed: 3083 additions & 37 deletions
File tree
- JSTests/wasm/stress
- Source
- JavaScriptCore
- JavaScriptCore.xcodeproj
- assembler
- b3
- air
- jit
- runtime
- wasm
- WTF/wtf
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
0 commit comments