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.
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))
Created attachment 373995 [details] Patch
Comment on attachment 373995 [details] Patch r=me.
Comment on attachment 373995 [details] Patch Clearing flags on attachment: 373995 Committed r247390: <https://trac.webkit.org/changeset/247390>
All reviewed patches have been landed. Closing bug.
<rdar://problem/53014344>