Bug 174750

Summary: B3 should do LICM
Product: WebKit Reporter: Filip Pizlo <fpizlo>
Component: JavaScriptCoreAssignee: Filip Pizlo <fpizlo>
Status: RESOLVED FIXED    
Severity: Normal CC: ggaren, jfbastien, keith_miller, mark.lam, msaboff, saam, ysuzuki
Priority: P2    
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 174762, 174763    
Attachments:
Description Flags
it's a start
none
more
none
more
none
wrote the pre-header creation
none
more
none
better version
none
added comprehensive tests and made them pass
none
added changelog
none
rebased
none
the patch keith_miller: review+

Filip Pizlo
Reported 2017-07-21 22:46:25 PDT
Patch forthcoming.
Attachments
it's a start (29.00 KB, patch)
2017-07-21 22:47 PDT, Filip Pizlo
no flags
more (66.03 KB, patch)
2017-07-22 08:26 PDT, Filip Pizlo
no flags
more (70.48 KB, patch)
2017-07-22 09:00 PDT, Filip Pizlo
no flags
wrote the pre-header creation (76.93 KB, patch)
2017-07-22 09:56 PDT, Filip Pizlo
no flags
more (80.28 KB, patch)
2017-07-22 21:11 PDT, Filip Pizlo
no flags
better version (78.79 KB, patch)
2017-07-23 11:26 PDT, Filip Pizlo
no flags
added comprehensive tests and made them pass (93.27 KB, patch)
2017-07-23 13:00 PDT, Filip Pizlo
no flags
added changelog (100.49 KB, patch)
2017-07-23 13:10 PDT, Filip Pizlo
no flags
rebased (98.51 KB, patch)
2017-07-23 13:18 PDT, Filip Pizlo
no flags
the patch (99.13 KB, patch)
2017-07-23 15:38 PDT, Filip Pizlo
keith_miller: review+
Filip Pizlo
Comment 1 2017-07-21 22:47:33 PDT
Created attachment 316175 [details] it's a start
Filip Pizlo
Comment 2 2017-07-22 08:26:09 PDT
Filip Pizlo
Comment 3 2017-07-22 09:00:24 PDT
Created attachment 316195 [details] more The LICM itself is written, now I need to write the pre-header creator.
Filip Pizlo
Comment 4 2017-07-22 09:56:21 PDT
Created attachment 316196 [details] wrote the pre-header creation
Filip Pizlo
Comment 5 2017-07-22 10:03:02 PDT
Actually, as awesome as this is, I don't think this is the way we want to handle optimizing caging. If a butterfly is used both caged and uncaged, we want to do the caging once and drop the uncaged value just to relieve register pressure.
Filip Pizlo
Comment 6 2017-07-22 21:11:44 PDT
Filip Pizlo
Comment 7 2017-07-23 11:26:19 PDT
Created attachment 316229 [details] better version I realized that InnerMostLoopIndices should be managed by a typename Graph::template Map.
Filip Pizlo
Comment 8 2017-07-23 13:00:41 PDT
Created attachment 316230 [details] added comprehensive tests and made them pass
Filip Pizlo
Comment 9 2017-07-23 13:10:19 PDT
Created attachment 316231 [details] added changelog
Filip Pizlo
Comment 10 2017-07-23 13:18:31 PDT
Filip Pizlo
Comment 11 2017-07-23 15:38:47 PDT
Created attachment 316241 [details] the patch
Keith Miller
Comment 12 2017-07-25 00:34:37 PDT
Comment on attachment 316241 [details] the patch View in context: https://bugs.webkit.org/attachment.cgi?id=316241&action=review r=me with some nits. > Source/JavaScriptCore/ChangeLog:8 > + Added a LICM phase to B3. This phase is called hoistLoopInvariantValues, to conform to the B3 naming I dunno HLIV doesn't roll off the tongue the same way LICM does... > Source/JavaScriptCore/b3/B3BasicBlock.cpp:60 > - m_values[m_values.size() - 1] = value; > + m_values[m_values.size() - 2] = value; legit... > Source/JavaScriptCore/b3/B3CFG.h:62 > + revert please. > Source/JavaScriptCore/b3/B3EnsureLoopPreHeaders.cpp:71 > + loop.header()->addPredecessor(preHeader); Nit: It would probably be a little clearer if you moved this line to where you set the successor of the preHeader.
Saam Barati
Comment 13 2017-07-25 11:13:45 PDT
Comment on attachment 316241 [details] the patch View in context: https://bugs.webkit.org/attachment.cgi?id=316241&action=review > Source/WTF/wtf/NaturalLoops.h:279 > + return 0; Nit: nullptr > Source/WTF/wtf/NaturalLoops.h:293 > + return 0; ditto > Source/WTF/wtf/NaturalLoops.h:300 > + return 0; ditto
Saam Barati
Comment 14 2017-07-25 12:15:51 PDT
Comment on attachment 316241 [details] the patch View in context: https://bugs.webkit.org/attachment.cgi?id=316241&action=review LGTM too > Source/JavaScriptCore/ChangeLog:20 > + This isn't super important. It's perf-neutral on JS benchmarks. FTL already does LICM on DFG SSA IR, and > + probably all current WebAssembly content has had LICM done to it. That being said, this is a cheap phase > + so it doesn't hurt to have it. It'd be interesting to compile some Wasm using -O0 and see if this is a speedup. I'd bet it is.
Keith Miller
Comment 15 2017-07-25 12:17:54 PDT
(In reply to Saam Barati from comment #14) > Comment on attachment 316241 [details] > the patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=316241&action=review > > LGTM too > > > Source/JavaScriptCore/ChangeLog:20 > > + This isn't super important. It's perf-neutral on JS benchmarks. FTL already does LICM on DFG SSA IR, and > > + probably all current WebAssembly content has had LICM done to it. That being said, this is a cheap phase > > + so it doesn't hurt to have it. > > It'd be interesting to compile some Wasm using -O0 and see if this is a > speedup. I'd bet it is. I'm not sure it would be since we don't have abstract heaps yet in wasm. That was on my todo but I never got around to it. But we should totally do this...
Filip Pizlo
Comment 16 2017-07-25 12:37:15 PDT
(In reply to Keith Miller from comment #15) > (In reply to Saam Barati from comment #14) > > Comment on attachment 316241 [details] > > the patch > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=316241&action=review > > > > LGTM too > > > > > Source/JavaScriptCore/ChangeLog:20 > > > + This isn't super important. It's perf-neutral on JS benchmarks. FTL already does LICM on DFG SSA IR, and > > > + probably all current WebAssembly content has had LICM done to it. That being said, this is a cheap phase > > > + so it doesn't hurt to have it. > > > > It'd be interesting to compile some Wasm using -O0 and see if this is a > > speedup. I'd bet it is. > > I'm not sure it would be since we don't have abstract heaps yet in wasm. > That was on my todo but I never got around to it. But we should totally do > this... It'll be a speed-up if we hoist division or multiplication. Also, for float code, if you can hoist basically anything then you get faster.
Filip Pizlo
Comment 17 2017-07-25 12:39:53 PDT
Comment on attachment 316241 [details] the patch View in context: https://bugs.webkit.org/attachment.cgi?id=316241&action=review >> Source/JavaScriptCore/b3/B3EnsureLoopPreHeaders.cpp:71 >> + loop.header()->addPredecessor(preHeader); > > Nit: It would probably be a little clearer if you moved this line to where you set the successor of the preHeader. Good point. Will do.
Filip Pizlo
Comment 18 2017-07-25 18:24:24 PDT
(In reply to Saam Barati from comment #13) > Comment on attachment 316241 [details] > the patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=316241&action=review > > > Source/WTF/wtf/NaturalLoops.h:279 > > + return 0; > > Nit: nullptr > > > Source/WTF/wtf/NaturalLoops.h:293 > > + return 0; > > ditto > > > Source/WTF/wtf/NaturalLoops.h:300 > > + return 0; > > ditto Fixed.
Filip Pizlo
Comment 19 2017-07-25 18:25:27 PDT
(In reply to Keith Miller from comment #12) > Comment on attachment 316241 [details] > the patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=316241&action=review > > r=me with some nits. > > > Source/JavaScriptCore/ChangeLog:8 > > + Added a LICM phase to B3. This phase is called hoistLoopInvariantValues, to conform to the B3 naming > > I dunno HLIV doesn't roll off the tongue the same way LICM does... > > > Source/JavaScriptCore/b3/B3BasicBlock.cpp:60 > > - m_values[m_values.size() - 1] = value; > > + m_values[m_values.size() - 2] = value; > > legit... > > > Source/JavaScriptCore/b3/B3CFG.h:62 > > + > > revert please. Fixed. > > > Source/JavaScriptCore/b3/B3EnsureLoopPreHeaders.cpp:71 > > + loop.header()->addPredecessor(preHeader); > > Nit: It would probably be a little clearer if you moved this line to where > you set the successor of the preHeader. Fixed.
Filip Pizlo
Comment 20 2017-07-25 18:26:48 PDT
(In reply to Filip Pizlo from comment #19) > (In reply to Keith Miller from comment #12) > > Comment on attachment 316241 [details] > > the patch > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=316241&action=review > > > > r=me with some nits. > > > > > Source/JavaScriptCore/ChangeLog:8 > > > + Added a LICM phase to B3. This phase is called hoistLoopInvariantValues, to conform to the B3 naming > > > > I dunno HLIV doesn't roll off the tongue the same way LICM does... > > > > > Source/JavaScriptCore/b3/B3BasicBlock.cpp:60 > > > - m_values[m_values.size() - 1] = value; > > > + m_values[m_values.size() - 2] = value; > > > > legit... > > > > > Source/JavaScriptCore/b3/B3CFG.h:62 > > > + > > > > revert please. > > Fixed. > > > > > > Source/JavaScriptCore/b3/B3EnsureLoopPreHeaders.cpp:71 > > > + loop.header()->addPredecessor(preHeader); > > > > Nit: It would probably be a little clearer if you moved this line to where > > you set the successor of the preHeader. > > Fixed. Actually no! My original ordering means that we first remove predecessors and then add. Your reordering, while clearer, would mean adding and then removing. It's a bit more efficient to remove then add, so I'll keep the current ordering.
Filip Pizlo
Comment 21 2017-07-25 18:59:00 PDT
Note You need to log in before you can comment on or make changes to this bug.