Avoid storing to the stack the same value just loaded from there
commit041d737d3f7835742855f5a22da98085701b7c39
authorottoni <ottoni@fb.com>
Thu, 14 Mar 2013 22:41:33 +0000 (14 15:41 -0700)
committerSara Golemon <sgolemon@fb.com>
Thu, 21 Mar 2013 23:13:20 +0000 (21 16:13 -0700)
tree7f9d772ba5705bedfc84a6f780bb4dc96bd290c4
parentd44f93f14ecaa2e8f038a520dc8f69d59abc05a9
Avoid storing to the stack the same value just loaded from there

Sometimes SpillStack and Call end up storing onto the stack a value
that was just loaded from the same stack location.  There was already
code in cgSpillStack to avoid the extra stores in some cases, but that
still kept the LdStack alive.  This diff detects some of those cases
with SpillStack in the Simplifier, which allows the LdStack to be
eliminated by DCE.  This diff also adds similar support for Call.  The
operands that don't need to be store onto the stack are replaced with
None.

Note that the optimization in cgSpillStack is not subsumed by this
diff.  In the Simplifier, we cannot chase through IncRefs as done in
cgSpillStack -- that would result in an IncRef that is not consumed.
hphp/doc/ir.specification
hphp/runtime/vm/translator/hopt/codegen.cpp
hphp/runtime/vm/translator/hopt/ir.cpp
hphp/runtime/vm/translator/hopt/simplifier.cpp
hphp/runtime/vm/translator/hopt/simplifier.h
hphp/runtime/vm/translator/hopt/tracebuilder.cpp
hphp/runtime/vm/translator/hopt/tracebuilder.h
hphp/runtime/vm/translator/hopt/type.cpp