NEW194222
Reduce the number of iterations in B3ReduceStrength
https://bugs.webkit.org/show_bug.cgi?id=194222
Summary Reduce the number of iterations in B3ReduceStrength
Robin Morisset
Reported 2019-02-04 09:47:10 PST
B3ReduceStrength repeats a sequence of optimizations to a fixpoint. One of these optimizations is a peephole optimizer, which currently does not revisit any node it adds or changes. So if it must be called 3 times to fully reduce an expression, the whole sequence of optimizations will be repeated 3 times (at least), even if the rest of the function was fully optimized in one pass. I'll try to make the peephole optimizer apply repeatedly whenever it adds/changes nodes, and measure how much it improves FTL compile-time.
Attachments
WIP (7.09 KB, patch)
2019-02-06 18:31 PST, Robin Morisset
no flags
WIP (6.85 KB, patch)
2019-02-06 18:45 PST, Robin Morisset
no flags
WIP_Arith (32.73 KB, patch)
2019-02-07 14:52 PST, Robin Morisset
no flags
WIP_Arith+Shifts+FP (46.78 KB, patch)
2019-02-07 16:25 PST, Robin Morisset
no flags
WIP_More (82.28 KB, patch)
2019-02-07 18:01 PST, Robin Morisset
no flags
Robin Morisset
Comment 1 2019-02-06 11:02:26 PST
Here are some quick numbers for ARES-6: 1 62 2 351 3 997 4 848 5 108 6 18 Meaning that B3ReduceStrength runs only two iterations in 351 cases, runs 4 iterations in 848 cases, etc.. If nothing is done, I expect this to get worse as B3ReduceStrength is taught more optimizations (e.g. https://bugs.webkit.org/show_bug.cgi?id=194081). Since the entire pass is repeated on each iteration, reducing this number of iterations should directly improve B3 compile time.
Robin Morisset
Comment 2 2019-02-06 18:31:51 PST
Created attachment 361360 [details] WIP Only supports Mul with the new architecture so far. Is currently recursive, I may have to rearchitect it into an iterative approach if it causes stack issues.
Robin Morisset
Comment 3 2019-02-06 18:45:47 PST
Created attachment 361361 [details] WIP Simpler, and now most recursive calls are tail-recursive which should alleviate the stack concerns.
Robin Morisset
Comment 4 2019-02-07 14:52:27 PST
Created attachment 361452 [details] WIP_Arith Now supports Add/Sub/Neg/Mul/Div/UDiv/Mod/UMod. Also now takes a kind as argument instead of an opcode, to correctly deal with chill operations. Finally I commented out an optimization from https://bugs.webkit.org/show_bug.cgi?id=194250 that seems buggy while I investigate.
Robin Morisset
Comment 5 2019-02-07 16:25:49 PST
Created attachment 361467 [details] WIP_Arith+Shifts+FP Add shifts, rotations, abs, ceil, floor.
Robin Morisset
Comment 6 2019-02-07 18:01:47 PST
Created attachment 361480 [details] WIP_More Adds conversions, select, equal.
Robin Morisset
Comment 7 2019-02-09 14:19:08 PST
On further investigation, it appears that the peephole optimizations are not the bottleneck on the number of iterations in B3ReduceStrength. So I will make this bug an umbrella for other more precise bugs fixing the actual problems.
Note You need to log in before you can comment on or make changes to this bug.