Implement CheckType hoisting passnightly-2021.12.05
commit59ee8843142108bc64781b444512b455e534ca30
authorRick Lavoie <rlavoie@fb.com>
Sat, 4 Dec 2021 07:03:30 +0000 (3 23:03 -0800)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Sat, 4 Dec 2021 07:05:00 +0000 (3 23:05 -0800)
treed568bbd9c1df88b8320c35e55ff84fd313cbcea5
parent3b92b772cddca8a6064decbfa7ae8b37ef22347a
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
hphp/runtime/base/runtime-option.h
hphp/runtime/vm/jit/check-type-opts.cpp [new file with mode: 0644]
hphp/runtime/vm/jit/opt.cpp
hphp/runtime/vm/jit/opt.h
hphp/runtime/vm/jit/reorder-check-types.cpp [deleted file]
hphp/runtime/vm/jit/timer.h
hphp/util/trace.h