Skip to content

Commit fa88418

Browse files
committed
[JSC] Do not use smull when shift is not following
https://bugs.webkit.org/show_bug.cgi?id=290274 rdar://147666338 Reviewed by Keith Miller. We found that using smull for MulHigh has slight perf regression when shift is not following after that. So this patch tweaks usage of that. * Source/JavaScriptCore/b3/B3ReduceStrength.cpp: Canonical link: https://commits.webkit.org/292564@main
1 parent e6c5f91 commit fa88418

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

Source/JavaScriptCore/b3/B3ReduceStrength.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -999,10 +999,14 @@ class ReduceStrength {
999999

10001000
Value* magicQuotient = nullptr;
10011001
if constexpr (isARM64() || isX86()) {
1002-
magicQuotient = m_insertionSet.insert<Value>(m_index, MulHigh, m_value->origin(),
1003-
dividend,
1004-
m_insertionSet.insert<Const32Value>(m_index, m_value->origin(), magic.magicMultiplier));
1005-
} else {
1002+
if (!(divisor > 0 && magic.magicMultiplier < 0) && !(divisor < 0 && magic.magicMultiplier > 0)) {
1003+
magicQuotient = m_insertionSet.insert<Value>(m_index, MulHigh, m_value->origin(),
1004+
dividend,
1005+
m_insertionSet.insert<Const32Value>(m_index, m_value->origin(), magic.magicMultiplier));
1006+
}
1007+
}
1008+
1009+
if (!magicQuotient) {
10061010
magicQuotient = m_insertionSet.insert<Value>(
10071011
m_index, Trunc, m_value->origin(),
10081012
m_insertionSet.insert<Value>(
@@ -1020,17 +1024,18 @@ class ReduceStrength {
10201024
if (divisor > 0 && magic.magicMultiplier < 0) {
10211025
magicQuotient = m_insertionSet.insert<Value>(
10221026
m_index, Add, m_value->origin(), magicQuotient, dividend);
1023-
}
1024-
if (divisor < 0 && magic.magicMultiplier > 0) {
1027+
} else if (divisor < 0 && magic.magicMultiplier > 0) {
10251028
magicQuotient = m_insertionSet.insert<Value>(
10261029
m_index, Sub, m_value->origin(), magicQuotient, dividend);
10271030
}
1031+
10281032
if (magic.shift > 0) {
10291033
magicQuotient = m_insertionSet.insert<Value>(
10301034
m_index, SShr, m_value->origin(), magicQuotient,
10311035
m_insertionSet.insert<Const32Value>(
10321036
m_index, m_value->origin(), magic.shift));
10331037
}
1038+
10341039
replaceWithIdentity(
10351040
m_insertionSet.insert<Value>(
10361041
m_index, Add, m_value->origin(), magicQuotient,

0 commit comments

Comments
 (0)