B3ReduceStrength: missing peephole optimizations for Neg and Sub
authorrmorisset@apple.com <rmorisset@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Feb 2019 18:36:36 +0000 (18:36 +0000)
committerrmorisset@apple.com <rmorisset@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Feb 2019 18:36:36 +0000 (18:36 +0000)
commitb88709bf42f556b70c85011e93e2f07d03814a03
treeeebfc92e184dbdeb525056d1e77a9c2fd64b05fa
parent826f76c04c495d219bf62c69e444cf2dc05d2fc5
B3ReduceStrength: missing peephole optimizations for Neg and Sub
https://bugs.webkit.org/show_bug.cgi?id=194250

Reviewed by Saam Barati.

Adds the following optimizations for integers:
- Sub(x, x) => 0
    Already covered by the test testSubArg
- Sub(x1, Neg(x2)) => Add (x1, x2)
    Added test: testSubNeg
- Neg(Sub(x1, x2)) => Sub(x2, x1)
    Added test: testNegSub
- Add(Neg(x1), x2) => Sub(x2, x1)
    Added test: testAddNeg1
- Add(x1, Neg(x2)) => Sub(x1, x2)
    Added test: testAddNeg2
Adds the following optimization for floating point values:
- Abs(Neg(x)) => Abs(x)
    Added test: testAbsNegArg
    Adds the following optimization:

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:
* b3/testb3.cpp:
(JSC::B3::testAddNeg1):
(JSC::B3::testAddNeg2):
(JSC::B3::testSubNeg):
(JSC::B3::testNegSub):
(JSC::B3::testAbsAbsArg):
(JSC::B3::testAbsNegArg):
(JSC::B3::run):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241126 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/b3/B3ReduceStrength.cpp
Source/JavaScriptCore/b3/testb3.cpp