diff options
author | 2022-07-22 15:21:29 +0100 | |
---|---|---|
committer | 2022-08-09 09:44:21 +0000 | |
commit | c6b816ceb2b35300c937ef2e7d008598b6afba21 (patch) | |
tree | 9bb081881ddd8e237521c9513c7ce6160fa6db11 /compiler/optimizing/nodes.h | |
parent | e6d405470c12c4dfd5f7757e9e951751a23622d3 (diff) |
Propagating values from if clauses to its successors
We have knowledge of the value of some variables at compile time due
to the fact they are used in if clauses. For example:
if (variable == constant) {
// SSA `variable` guaranteed to be equal to constant here.
} else {
// No guarantees can be made here (except for booleans since
// they only have two values).
}
Similarly with `variable != constant`.
We can also apply this to boolean parameters e.g.
void foo (boolean val) {
if (val) {
// `val` guaranteed to be true here.
...
}
...
}
Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b
Change-Id: I55df0252d672870993d06e5ac92f5bba44d902bd
Diffstat (limited to 'compiler/optimizing/nodes.h')
-rw-r--r-- | compiler/optimizing/nodes.h | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h index 1ceb8f118a..ed2f2111b2 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -2444,9 +2444,12 @@ class HInstruction : public ArenaObject<kArenaAllocInstruction> { return IsRemovable() && !HasUses(); } - // Does this instruction strictly dominate `other_instruction`? - // Returns false if this instruction and `other_instruction` are the same. - // Aborts if this instruction and `other_instruction` are both phis. + // Does this instruction dominate `other_instruction`? + // Aborts if this instruction and `other_instruction` are different phis. + bool Dominates(HInstruction* other_instruction) const; + + // Same but with `strictly dominates` i.e. returns false if this instruction and + // `other_instruction` are the same. bool StrictlyDominates(HInstruction* other_instruction) const; int GetId() const { return id_; } @@ -2511,7 +2514,9 @@ class HInstruction : public ArenaObject<kArenaAllocInstruction> { void SetLocations(LocationSummary* locations) { locations_ = locations; } void ReplaceWith(HInstruction* instruction); - void ReplaceUsesDominatedBy(HInstruction* dominator, HInstruction* replacement); + void ReplaceUsesDominatedBy(HInstruction* dominator, + HInstruction* replacement, + bool strictly_dominated = true); void ReplaceEnvUsesDominatedBy(HInstruction* dominator, HInstruction* replacement); void ReplaceInput(HInstruction* replacement, size_t index); |