Bug 150775

Summary: B3::LowerToAir should do copy propagation
Product: WebKit Reporter: Filip Pizlo <fpizlo>
Component: JavaScriptCoreAssignee: Filip Pizlo <fpizlo>
Status: RESOLVED FIXED    
Severity: Normal CC: barraclough, benjamin, ggaren, mark.lam, mhahnenb, msaboff, nrotem, oliver, saam, sam
Priority: P2    
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 150279, 150845    
Attachments:
Description Flags
the patch
none
the patch ggaren: review+

Description Filip Pizlo 2015-11-01 09:19:09 PST
For example, the Trunc value in B3 is really just an identity in Air.  Currently we emit a Move.  But, it would be more efficient to copy propagate: just set the tmp of the Trunc to the tmp of the input.

We could do similar things for ZExt and SExt.  For ZExt, we could record if the tmp for the input value was produced by an instruction that already zero-extends.  For SExt, we could record if the tmp for the input value was produced by an instruction that already sign-extends.  For both of them, we could also use an analysis of whether the input is non-negative.  If so, the we could copy-propagate through ZExt and SExt provided that the source either zero- or sign-extended.  For example, we could copy-prop through a SExt if the source zero-extended and the value is proved non-negative.
Comment 1 Filip Pizlo 2015-11-01 09:20:45 PST
Interestingly though, we may not need to do anything special for SExt.  The FTL is already smart enough to use ZExt in all those cases where the input is non-negative.
Comment 2 Filip Pizlo 2015-11-03 12:24:06 PST
Created attachment 264709 [details]
the patch
Comment 3 Filip Pizlo 2015-11-03 12:27:10 PST
Created attachment 264710 [details]
the patch
Comment 4 Geoffrey Garen 2015-11-03 13:13:53 PST
Comment on attachment 264710 [details]
the patch

r=me
Comment 5 Filip Pizlo 2015-11-03 14:05:02 PST
Landed in http://trac.webkit.org/changeset/191977