Lines Matching refs:instruction

36   ValueBound(HInstruction* instruction, int32_t constant) {
37 if (instruction != nullptr && instruction->IsIntConstant()) {
38 // Normalize ValueBound with constant instruction.
39 int32_t instr_const = instruction->AsIntConstant()->GetValue();
46 instruction_ = instruction;
66 // Return true if instruction can be expressed as "left_instruction + right_constant".
67 static bool IsAddOrSubAConstant(HInstruction* instruction,
72 while (instruction->IsAdd() || instruction->IsSub()) {
73 HBinaryOperation* bin_op = instruction->AsBinaryOperation();
78 int32_t c = instruction->IsAdd() ? v : -v;
80 instruction = left;
94 // Expresses any instruction as a value bound.
95 static ValueBound AsValueBound(HInstruction* instruction) {
96 if (instruction->IsIntConstant()) {
97 return ValueBound(nullptr, instruction->AsIntConstant()->GetValue());
101 if (IsAddOrSubAConstant(instruction, &left, &right)) {
104 return ValueBound(instruction, 0);
107 // Try to detect useful value bound format from an instruction, e.g.
109 static ValueBound DetectValueBoundFromValue(HInstruction* instruction, /* out */ bool* found) {
110 DCHECK(instruction != nullptr);
111 if (instruction->IsIntConstant()) {
113 return ValueBound(nullptr, instruction->AsIntConstant()->GetValue());
116 if (instruction->IsArrayLength()) {
118 return ValueBound(instruction, 0);
123 if (IsAddOrSubAConstant(instruction, &left, &right)) {
139 // Some bounds are created with HNewArray* as the instruction instead
162 static HInstruction* HuntForDeclaration(HInstruction* instruction) {
163 while (instruction->IsArrayLength() ||
164 instruction->IsNullCheck() ||
165 instruction->IsNewArray()) {
166 instruction = instruction->InputAt(0);
168 return instruction;
593 ValueRange* LookupValueRange(HInstruction* instruction, HBasicBlock* basic_block) {
597 if (map->find(instruction->GetId()) != map->end()) {
598 return map->Get(instruction->GetId());
609 // Helper method to assign a new range to an instruction in given basic block.
610 void AssignRange(HBasicBlock* basic_block, HInstruction* instruction, ValueRange* range) {
611 GetValueRangeMap(basic_block)->Overwrite(instruction->GetId(), range);
614 // Narrow the value range of `instruction` at the end of `basic_block` with `range`,
616 void ApplyRangeFromComparison(HInstruction* instruction, HBasicBlock* basic_block,
618 ValueRange* existing_range = LookupValueRange(instruction, basic_block);
621 AssignRange(successor, instruction, range);
626 DCHECK(instruction->IsLoopHeaderPhi());
629 if (instruction->GetBlock() != basic_block) {
633 AssignRange(successor, instruction, existing_range->Narrow(range));
638 void HandleIfBetweenTwoMonotonicValueRanges(HIf* instruction,
646 if (instruction->GetBlock() != left->GetBlock()) {
664 successor = instruction->IfTrueSuccessor();
666 successor = instruction->IfTrueSuccessor();
668 successor = instruction->IfFalseSuccessor();
672 successor = instruction->IfFalseSuccessor();
687 ApplyRangeFromComparison(left, instruction->GetBlock(), successor,
696 ApplyRangeFromComparison(right, instruction->GetBlock(), successor,
704 void HandleIf(HIf* instruction, HInstruction* left, HInstruction* right, IfCondition cond) {
705 HBasicBlock* block = instruction->GetBlock();
707 HBasicBlock* true_successor = instruction->IfTrueSuccessor();
711 HBasicBlock* false_successor = instruction->IfFalseSuccessor();
721 if (instruction->GetBlock() != loop_head) {
722 // For monotonic value range, don't handle `instruction`
742 HandleIfBetweenTwoMonotonicValueRanges(instruction, left, right, cond,
885 // instruction has an associated HEnvironment where we may add an HDeoptimize
912 HInstruction* instruction = phi->InputAt(1);
915 if (ValueBound::IsAddOrSubAConstant(instruction, &left, &increment)) {
955 void VisitIf(HIf* instruction) OVERRIDE {
956 if (instruction->InputAt(0)->IsCondition()) {
957 HCondition* cond = instruction->InputAt(0)->AsCondition();
963 HandleIf(instruction, left, right, cmp);
1041 void FindAndHandlePartialArrayLength(HBinaryOperation* instruction) {
1042 DCHECK(instruction->IsDiv() || instruction->IsShr() || instruction->IsUShr());
1043 HInstruction* right = instruction->GetRight();
1048 if ((instruction->IsDiv() && right_const <= 1) ||
1049 (instruction->IsShr() && right_const < 1) ||
1050 (instruction->IsUShr() && right_const < 1)) {
1058 HInstruction* left = instruction->GetLeft();
1064 // The value of left input of instruction equals (left + c).
1070 if (instruction->IsUShr() && c < 0) {
1080 AssignRange(instruction->GetBlock(), instruction, range);
1096 void VisitAnd(HAnd* instruction) OVERRIDE {
1097 if (instruction->GetRight()->IsIntConstant()) {
1098 int32_t constant = instruction->GetRight()->AsIntConstant()->GetValue();
1106 AssignRange(instruction->GetBlock(), instruction, range);
1121 // which isn't available as an instruction yet. new_array will
1148 * unsafe to hoist array references across their deoptimization instruction inside a loop.
1205 // for a base instruction (possibly absent) and various constants. Note that no attempt
1296 DCHECK(v1.a_constant == 1 || v1.instruction == nullptr);
1297 DCHECK(v2.a_constant == 1 || v2.instruction == nullptr);
1299 ValueBound(v1.instruction, v1.b_constant),
1300 ValueBound(v2.instruction, v2.b_constant));
1324 bool TryDynamicBCE(HBoundsCheck* instruction) {
1325 HLoopInformation* loop = instruction->GetBlock()->GetLoopInformation();
1326 HInstruction* index = instruction->InputAt(0);
1327 HInstruction* length = instruction->InputAt(1);
1331 if (DynamicBCESeemsProfitable(loop, instruction->GetBlock()) &&
1333 instruction, index, &needs_finite_test, &needs_taken_test) &&
1334 CanHandleInfiniteLoop(loop, instruction, index, needs_finite_test) &&
1347 HBasicBlock* block = GetPreHeader(loop, instruction);
1348 induction_range_.GenerateRangeCode(instruction, index, GetGraph(), block, &lower, &upper);
1353 ReplaceInstruction(instruction, index);
1499 * instruction appears in the loop header or proper loop-body.
1501 HBasicBlock* GetPreHeader(HLoopInformation* loop, HInstruction* instruction) {
1511 if (instruction->GetBlock() == header) {
1542 /** Hoists instruction out of the loop to preheader or deoptimization block. */
1543 void HoistToPreHeaderOrDeoptBlock(HLoopInformation* loop, HInstruction* instruction) {
1544 HBasicBlock* block = GetPreHeader(loop, instruction);
1545 DCHECK(!instruction->HasEnvironment());
1546 instruction->MoveBefore(block->GetLastInstruction());
1641 HInstruction* instruction = it.Current();
1642 Primitive::Type type = instruction->GetType();
1644 // Scan all uses of an instruction and replace each later use with a phi node.
1645 const HUseList<HInstruction*>& uses = instruction->GetUses();
1653 phi = NewPhi(new_preheader, instruction, type);
1658 // Scan all environment uses of an instruction and replace each later use with a phi node.
1659 const HUseList<HEnvironment*>& env_uses = instruction->GetEnvUses();
1667 phi = NewPhi(new_preheader, instruction, type);
1679 * Construct a phi(instruction, 0) in the new preheader to fix the dominance relation.
1683 HInstruction* instruction,
1695 phi->SetRawInputAt(0, instruction);
1698 phi->SetReferenceTypeInfo(instruction->GetReferenceTypeInfo());
1704 /** Helper method to replace an instruction with another instruction. */
1705 static void ReplaceInstruction(HInstruction* instruction, HInstruction* replacement) {
1706 instruction->ReplaceWith(replacement);
1707 instruction->GetBlock()->RemoveInstruction(instruction);
1710 // A set of maps, one per basic block, from instruction to range.
1713 // Map an HArrayLength instruction's id to the first HBoundsCheck instruction
1752 // be bounded by a range at one instruction, it must be true that all uses of
1753 // that value dominated by that instruction fits in that range. Range of that