23 if ((env_use->instruction() != block) &&
32bool BranchSimplifier::Match(JoinEntryInstr* block) {
44 ComparisonInstr* comparison = branch->comparison();
45 if (comparison->InputCount() != 2) {
48 if (comparison->CanDeoptimize() || comparison->MayThrow()) {
52 PhiInstr* phi =
left->definition()->AsPhi();
54 ConstantInstr* constant =
55 (
right ==
nullptr) ?
nullptr :
right->definition()->AsConstant();
56 return (phi !=
nullptr) && (constant !=
nullptr) &&
58 (block->next() == branch) && (block->phis()->length() == 1);
70 join->set_last_instruction(
target->last_instruction());
77 auto replacement =
new (zone)
80 replacement->LinkTo(
target->next());
81 replacement->set_last_instruction(
target->last_instruction());
121 bool changed =
false;
139 ASSERT(branch !=
nullptr);
146 ASSERT(constant !=
nullptr);
151 ASSERT(old_goto !=
nullptr);
156 Value* new_right =
new (zone)
Value(constant);
158 CloneBranch(zone, branch, new_left, new_right);
159 if (branch->
env() ==
nullptr) {
182 if (branch_block->IsJoinEntry())
worklist.Add(branch_block);
197 true_target->
LinkTo(goto_true);
202 false_target->
LinkTo(goto_false);
225 ((block->
next() == defn) &&
235 if ((block->
next() == instr) &&
244 bool changed =
false;
271 if ((
join !=
nullptr) && (
join->phis() !=
nullptr) &&
286 if (branch ==
nullptr) {
intptr_t try_index() const
void set_block_id(intptr_t block_id)
intptr_t block_id() const
virtual intptr_t PredecessorCount() const =0
virtual BlockEntryInstr * PredecessorAt(intptr_t index) const =0
void set_last_instruction(Instruction *instr)
Instruction * last_instruction() const
TargetEntryInstr ** false_successor_address()
TargetEntryInstr * false_successor() const
TargetEntryInstr ** true_successor_address()
TargetEntryInstr * true_successor() const
ComparisonInstr * comparison() const
static TargetEntryInstr * ToTargetEntry(Zone *zone, BlockEntryInstr *target)
static JoinEntryInstr * ToJoinEntry(Zone *zone, BlockEntryInstr *target)
static void Simplify(FlowGraph *flow_graph)
void SetDeoptId(const Instruction &instr)
virtual ComparisonInstr * CopyWithNewOperands(Value *left, Value *right)=0
Value * env_use_list() const
Value * input_use_list() const
void ReplaceUsesWith(Definition *other)
static constexpr intptr_t kNone
intptr_t max_block_id() const
const GrowableArray< BlockEntryInstr * > & postorder() const
void ComputeDominators(GrowableArray< BitVector * > *dominance_frontier)
void set_max_block_id(intptr_t id)
void InsertBefore(Instruction *next, Instruction *instr, Environment *env, UseKind use_kind)
static void Simplify(FlowGraph *flow_graph)
static bool Supports(ComparisonInstr *comparison, Value *v1, Value *v2)
void InsertBefore(Instruction *next)
Instruction * next() const
void LinkTo(Instruction *next)
void InheritDeoptTarget(Zone *zone, Instruction *other)
virtual BlockEntryInstr * GetBlock()
Environment * env() const
void set_next(Instruction *instr)
void ReplaceInEnvironment(Definition *current, Definition *replacement)
Instruction * previous() const
virtual BlockEntryInstr * PredecessorAt(intptr_t index) const
virtual intptr_t PredecessorCount() const
JoinEntryInstr * block() const
Instruction * instruction() const
Definition * definition() const
Value * InputAt(intptr_t i) const
static bool IsTrivialBlock(BlockEntryInstr *block, Definition *defn)
static bool PhiHasSingleUse(PhiInstr *phi, Value *use)
static void EliminateTrivialBlock(BlockEntryInstr *block, Definition *instr, IfThenElseInstr *before)
static SkString join(const CommandLineFlags::StringArray &)