Bug 196371 - B3 should reduce (integer) Sub(Neg(x), y) to Neg(Add(x, y))
Summary: B3 should reduce (integer) Sub(Neg(x), y) to Neg(Add(x, y))
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Justin Michaud
URL:
Keywords: InRadar
Depends on:
Blocks: 196361
  Show dependency treegraph
 
Reported: 2019-03-28 12:46 PDT by Robin Morisset
Modified: 2019-07-12 10:29 PDT (History)
9 users (show)

See Also:


Attachments
Patch (7.81 KB, patch)
2019-07-11 20:11 PDT, Justin Michaud
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Robin Morisset 2019-03-28 12:46:08 PDT
It does not reduce the number of operation, but is a useful canonicalization in a few ways:
- improves the chance for CSE to work
- floating the Neg outwards maximizes the chance it will get eliminated
- it is generally easier to optimize Add (which is associative on integers) than Sub.
Comment 1 Robin Morisset 2019-06-27 11:22:18 PDT
Other similar reduction rules that would be useful (look at https://bugs.webkit.org/show_bug.cgi?id=199203 for an example where rules 1 and 3 would allow a lot of simplifications):
Sub(Sub(a, b), c) => Sub(a, Add(b, c))
Sub(a, Sub(b, c)) => Sub(Add(a, c), b)
Sub(Add(a, b), c) => Add(a, Sub(b, c))
Comment 2 Justin Michaud 2019-07-11 20:11:57 PDT
Created attachment 373995 [details]
Patch
Comment 3 Keith Miller 2019-07-11 20:19:20 PDT
Comment on attachment 373995 [details]
Patch

r=me.
Comment 4 WebKit Commit Bot 2019-07-12 10:11:37 PDT
Comment on attachment 373995 [details]
Patch

Clearing flags on attachment: 373995

Committed r247390: <https://trac.webkit.org/changeset/247390>
Comment 5 WebKit Commit Bot 2019-07-12 10:11:38 PDT
All reviewed patches have been landed.  Closing bug.
Comment 6 Radar WebKit Bug Importer 2019-07-12 10:14:04 PDT
<rdar://problem/53014344>