ART: Make GVN work with BoundType.
Support BoundType instruction treatment in GVN.
Note: BoundType must not be a subject to LICM as it must not be
moved from more control dependent basic blocks to less control
dependent (e.g. hoisted out from the loop) due to semantics of
bounding the type.
Test: 477-checker-bound-type.
Test: test-art-target, test-art-host.
Change-Id: I64263d6ec7d9ad75d1fb07d3a89e9973be67682b
diff --git a/compiler/optimizing/gvn.cc b/compiler/optimizing/gvn.cc
index 4863718..e6b6326 100644
--- a/compiler/optimizing/gvn.cc
+++ b/compiler/optimizing/gvn.cc
@@ -479,7 +479,10 @@
HInstruction* next = current->GetNext();
// Do not kill the set with the side effects of the instruction just now: if
// the instruction is GVN'ed, we don't need to kill.
- if (current->CanBeMoved()) {
+ //
+ // BoundType is a special case example of an instruction which shouldn't be moved but can be
+ // GVN'ed.
+ if (current->CanBeMoved() || current->IsBoundType()) {
if (current->IsBinaryOperation() && current->AsBinaryOperation()->IsCommutative()) {
// For commutative ops, (x op y) will be treated the same as (y op x)
// after fixed ordering.