WebKit Bugzilla
Attachment 361134 Details for
Bug 194250
: B3ReduceStrength: missing peephole optimizations for Neg and Sub
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194250-20190204171218.patch (text/plain), 6.02 KB, created by
Robin Morisset
on 2019-02-04 17:12:19 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Robin Morisset
Created:
2019-02-04 17:12:19 PST
Size:
6.02 KB
patch
obsolete
>Index: Source/JavaScriptCore/ChangeLog >=================================================================== >--- Source/JavaScriptCore/ChangeLog (revision 240949) >+++ Source/JavaScriptCore/ChangeLog (working copy) >@@ -1,3 +1,22 @@ >+2019-02-04 Robin Morisset <rmorisset@apple.com> >+ >+ B3ReduceStrength: missing peephole optimizations for Neg and Sub >+ https://bugs.webkit.org/show_bug.cgi?id=194250 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Adds the following optimizations for integers: >+ - Sub(x, x) => 0 >+ - Sub(x1, Neg(x2)) => Add (x1, x2) >+ - Abs(Neg(x)) => Abs(x) (not limited to integers) >+ - Neg(Sub(x1, x2)) => Sub(x2, x1) >+ - Add(x1, Neg(x2)) => Sub(x1, x2) >+ - Add(Neg(x1), x2) => Sub(x2, x1) >+ >+ Also did some trivial refactoring, using m_value->isInteger() everywhere instead of isInt(m_value->type()), and using replaceWithNew<Value> instead of replaceWithNewValue(m_proc.add<Value(..)) >+ >+ * b3/B3ReduceStrength.cpp: >+ > 2019-02-04 Yusuke Suzuki <ysuzuki@apple.com> > > [JSC] Shrink size of FunctionExecutable >Index: Source/JavaScriptCore/b3/B3ReduceStrength.cpp >=================================================================== >--- Source/JavaScriptCore/b3/B3ReduceStrength.cpp (revision 240935) >+++ Source/JavaScriptCore/b3/B3ReduceStrength.cpp (working copy) >@@ -499,7 +499,7 @@ private: > case Add: > handleCommutativity(); > >- if (m_value->child(0)->opcode() == Add && isInt(m_value->type())) { >+ if (m_value->child(0)->opcode() == Add && m_value->isInteger()) { > // Turn this: Add(Add(value, constant1), constant2) > // Into this: Add(value, constant1 + constant2) > Value* newSum = m_value->child(1)->addConstant(m_proc, m_value->child(0)->child(1)); >@@ -532,7 +532,7 @@ private: > > // Turn this: Add(otherValue, Add(value, constant)) > // Into this: Add(Add(value, otherValue), constant) >- if (isInt(m_value->type()) >+ if (m_value->isInteger() > && !m_value->child(0)->hasInt() > && m_value->child(1)->opcode() == Add > && m_value->child(1)->child(1)->hasInt()) { >@@ -579,14 +579,29 @@ private: > break; > } > >- // Turn this: Integer Add(Sub(0, value), -1) >- // Into this: BitXor(value, -1) >- if (m_value->isInteger() >- && m_value->child(0)->opcode() == Sub >- && m_value->child(1)->isInt(-1) >- && m_value->child(0)->child(0)->isInt(0)) { >- replaceWithNewValue(m_proc.add<Value>(BitXor, m_value->origin(), m_value->child(0)->child(1), m_value->child(1))); >- break; >+ if (m_value->isInteger()) { >+ // Turn this: Integer Add(value, Neg(otherValue)) >+ // Into this: Sub(value, otherValue) >+ if (m_value->child(1)->opcode() == Neg) { >+ replaceWithNew<Value>(Sub, m_value->origin(), m_value->child(0), m_value->child(1)->child(0)); >+ break; >+ } >+ >+ // Turn this: Integer Add(Neg(value), otherValue) >+ // Into this: Sub(otherValue, value) >+ if (m_value->child(0)->opcode() == Neg) { >+ replaceWithNew<Value>(Sub, m_value->origin(), m_value->child(1), m_value->child(0)->child(0)); >+ break; >+ } >+ >+ // Turn this: Integer Add(Sub(0, value), -1) >+ // Into this: BitXor(value, -1) >+ if (m_value->child(0)->opcode() == Sub >+ && m_value->child(1)->isInt(-1) >+ && m_value->child(0)->child(0)->isInt(0)) { >+ replaceWithNew<Value>(BitXor, m_value->origin(), m_value->child(0)->child(1), m_value->child(1)); >+ break; >+ } > } > > break; >@@ -599,7 +614,7 @@ private: > break; > } > >- if (isInt(m_value->type())) { >+ if (m_value->isInteger()) { > // Turn this: Sub(value, constant) > // Into this: Add(value, -constant) > if (Value* negatedConstant = m_value->child(1)->negConstant(m_proc)) { >@@ -615,6 +630,20 @@ private: > replaceWithNew<Value>(Neg, m_value->origin(), m_value->child(1)); > break; > } >+ >+ // Turn this: Sub(value, value) >+ // Into this: 0 >+ if (m_value->child(0) == m_value->child(1)) { >+ replaceWithNewValue(m_proc.addIntConstant(m_value, 0)); >+ break; >+ } >+ >+ // Turn this: Sub(value, Neg(otherValue)) >+ // Into this: Add(value, otherValue) >+ if (m_value->child(1)->opcode() == Neg) { >+ replaceWithNew<Value>(Add, m_value->origin(), m_value->child(0), m_value->child(1)->child(0)); >+ break; >+ } > } > > break; >@@ -634,6 +663,13 @@ private: > break; > } > >+ // Turn this: Neg(Sub(value, otherValue)) >+ // Into this: Sub(otherValue, value) >+ if (m_value->child(0)->opcode() == Sub) { >+ replaceWithNew<Value>(Sub, m_value->origin(), m_value->child(0)->child(1), m_value->child(0)->child(0)); >+ break; >+ } >+ > break; > > case Mul: >@@ -1201,6 +1237,13 @@ private: > replaceWithIdentity(m_value->child(0)); > break; > } >+ >+ // Turn this: Abs(Neg(value)) >+ // Into this: Abs(value) >+ if (m_value->child(0)->opcode() == Neg) { >+ replaceWithIdentity(m_value->child(0)->child(0)); >+ break; >+ } > > // Turn this: Abs(BitwiseCast(value)) > // Into this: BitwiseCast(And(value, mask-top-bit))
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194250
:
361134
|
361215
|
361341