Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 2cd6a734ed6c4f1201d1adf4aedd04f6d03f96ea
https://github.com/WebKit/WebKit/commit/2cd6a734ed6c4f1201d1adf4aedd04f6d03f96ea
Author: Yusuke Suzuki <[email protected]>
Date: 2026-01-12 (Mon, 12 Jan 2026)
Changed paths:
M Source/JavaScriptCore/assembler/MacroAssemblerARM64.h
M Source/JavaScriptCore/b3/B3LowerToAir.cpp
M Source/JavaScriptCore/b3/air/AirOpcode.opcodes
M Source/JavaScriptCore/b3/air/AirOptimizeBlockOrder.cpp
M Source/JavaScriptCore/b3/testb3.h
M Source/JavaScriptCore/b3/testb3_1.cpp
M Source/JavaScriptCore/b3/testb3_8.cpp
Log Message:
-----------
[JSC] Implement ccmp / ccmn chain
https://bugs.webkit.org/show_bug.cgi?id=304917
rdar://167529315
Reviewed by Marcus Plutowski.
This patch implements chain of compare with ARM64 ccmp / ccmn.
Let's say,
if (x0 == 0 && x1 == 1) {
// target-block
}
Then this will be compiled via LLVM into wasm. And this will create
BitAnd(Equal(a, 0), Equal(b, 1)).
Then ARM64 ccmp can handle it as follows.
cmp x0, #0
ccmp x1, #1, #0, eq // cmp x1, #1 when flag is eq and override, otherwise
set #0 to flag
b.eq target-block
This reduces small weird basic blocks and reduces prediction miss, and
reduces code size.
We introduce CompareOnFlags, CompareConditionallyOnFlags, and
BranchOnFlags Air opcodes. All of them are annotated as /effects since
this relies on the current flag, and they are not producing register
output while it has side effects. This ensures that we are not removing
these instructions, and we are not hoisting etc. randomly.
We introduced V8's compare chain detection mechanism and using it for
chained cmp code generation.
Tests: Source/JavaScriptCore/b3/testb3_1.cpp
Source/JavaScriptCore/b3/testb3_8.cpp
* Source/JavaScriptCore/assembler/MacroAssemblerARM64.h:
(JSC::MacroAssemblerARM64::compareOnFlags32):
(JSC::MacroAssemblerARM64::compareOnFlags64):
(JSC::MacroAssemblerARM64::compareOnFlagsFloat):
(JSC::MacroAssemblerARM64::compareOnFlagsDouble):
(JSC::MacroAssemblerARM64::compareConditionallyOnFlags32):
(JSC::MacroAssemblerARM64::compareConditionallyOnFlags64):
(JSC::MacroAssemblerARM64::compareConditionallyOnFlagsFloat):
(JSC::MacroAssemblerARM64::compareConditionallyOnFlagsDouble):
(JSC::MacroAssemblerARM64::branchOnFlags):
* Source/JavaScriptCore/b3/B3LowerToAir.cpp:
* Source/JavaScriptCore/b3/air/AirOpcode.opcodes:
* Source/JavaScriptCore/b3/air/AirOptimizeBlockOrder.cpp:
(JSC::B3::Air::optimizeBlockOrder):
* Source/JavaScriptCore/b3/testb3.h:
* Source/JavaScriptCore/b3/testb3_1.cpp:
(run):
* Source/JavaScriptCore/b3/testb3_8.cpp:
(testCCmpAnd32):
(testCCmpAnd64):
(testCCmpOr32):
(testCCmpOr64):
(testCCmpAndAnd32):
(testCCmpOrOr32):
(testCCmpAndOr32):
(testCCmnAnd32WithNegativeImm):
(testCCmnAnd64WithNegativeImm):
(testCCmpWithLargePositiveImm):
(testCCmpWithLargeNegativeImm):
(testCCmpSmartOperandOrdering32):
(testCCmpSmartOperandOrdering64):
(testCCmpOperandCommutation32):
(testCCmpOperandCommutation64):
(testCCmpCombinedOptimizations):
(testCCmpZeroRegisterOptimization32):
(testCCmpZeroRegisterOptimization64):
(testCCmpMixedAndOr32):
(testCCmpMixedOrAnd32):
(testCCmpNegatedAnd32):
(testCCmpNegatedOr32):
(testCCmpMixedWidth32And64):
(testCCmpMixedWidth64And32):
Canonical link: https://commits.webkit.org/305493@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications