Implement CheckType hoisting pass
Summary:
Add a pass which attempts to hoist CheckTypes above DefLabels in the
same block which define the SSATmp being checked. This can allow us to
do the CheckType on a more refined type, possibly letting the
CheckType be optimized away.See comments for details about the
mechanism of the pass.
This type of pattern is fairly common, and its also a side-effect of
the bespoke lowering pass, as that tends to create diamonds which are
immediately tested again.
Lump this pass in with the reorderCheckTypes pass and execute as one
(called optimizeCheckTypes). Trigger it a few times in the
optimization pipeline (the pass is cheaper if nothing needs to be
done). The pass leaves the CFG in a layout which usually can be
optimized further. So, if the pass is successful, run a few other
passes to clean things up.
Since hoisting the CheckType can open up other opportunities for
further CheckType hoisting, execute the pass in a loop (including
clean up passes). Stop when nothing more is hoisted.
Reviewed By: ottoni
Differential Revision:
D32692325
fbshipit-source-id:
b7594277992c85eb83c597c9596f8fd5e2bad44a