buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
buzbee | 395116c | 2013-02-27 14:30:25 -0800 | [diff] [blame^] | 17 | #include "compiler/dex/compiler_internals.h" |
buzbee | 1bc37c6 | 2012-11-20 13:35:41 -0800 | [diff] [blame] | 18 | |
Elliott Hughes | 11d1b0c | 2012-01-23 16:57:47 -0800 | [diff] [blame] | 19 | namespace art { |
| 20 | |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 21 | #define DEBUG_OPT(X) |
| 22 | |
Ian Rogers | 07ec8e1 | 2012-12-01 01:26:51 -0800 | [diff] [blame] | 23 | /* Check RAW, WAR, and RAW dependency on the register operands */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 24 | #define CHECK_REG_DEP(use, def, check) ((def & check->use_mask) || \ |
| 25 | ((use | def) & check->def_mask)) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 26 | |
| 27 | /* Scheduler heuristics */ |
| 28 | #define MAX_HOIST_DISTANCE 20 |
| 29 | #define LDLD_DISTANCE 4 |
| 30 | #define LD_LATENCY 2 |
| 31 | |
buzbee | aad9438 | 2012-11-21 07:40:50 -0800 | [diff] [blame] | 32 | static bool IsDalvikRegisterClobbered(LIR* lir1, LIR* lir2) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 33 | { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 34 | int reg1Lo = DECODE_ALIAS_INFO_REG(lir1->alias_info); |
| 35 | int reg1Hi = reg1Lo + DECODE_ALIAS_INFO_WIDE(lir1->alias_info); |
| 36 | int reg2Lo = DECODE_ALIAS_INFO_REG(lir2->alias_info); |
| 37 | int reg2Hi = reg2Lo + DECODE_ALIAS_INFO_WIDE(lir2->alias_info); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 38 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 39 | return (reg1Lo == reg2Lo) || (reg1Lo == reg2Hi) || (reg1Hi == reg2Lo); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | /* Convert a more expensive instruction (ie load) into a move */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 43 | static void ConvertMemOpIntoMove(CompilationUnit* cu, LIR* orig_lir, int dest, int src) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 44 | { |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 45 | Codegen* cg = cu->cg.get(); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 46 | /* Insert a move to replace the load */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 47 | LIR* move_lir; |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 48 | move_lir = cg->OpRegCopyNoInsert( cu, dest, src); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 49 | /* |
| 50 | * Insert the converted instruction after the original since the |
| 51 | * optimization is scannng in the top-down order and the new instruction |
| 52 | * will need to be re-checked (eg the new dest clobbers the src used in |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 53 | * this_lir). |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 54 | */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 55 | InsertLIRAfter(orig_lir, move_lir); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | /* |
| 59 | * Perform a pass of top-down walk, from the second-last instruction in the |
| 60 | * superblock, to eliminate redundant loads and stores. |
| 61 | * |
| 62 | * An earlier load can eliminate a later load iff |
| 63 | * 1) They are must-aliases |
| 64 | * 2) The native register is not clobbered in between |
| 65 | * 3) The memory location is not written to in between |
| 66 | * |
| 67 | * An earlier store can eliminate a later load iff |
| 68 | * 1) They are must-aliases |
| 69 | * 2) The native register is not clobbered in between |
| 70 | * 3) The memory location is not written to in between |
| 71 | * |
| 72 | * A later store can be eliminated by an earlier store iff |
| 73 | * 1) They are must-aliases |
| 74 | * 2) The memory location is not written to in between |
| 75 | */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 76 | static void ApplyLoadStoreElimination(CompilationUnit* cu, LIR* head_lir, LIR* tail_lir) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 77 | { |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 78 | Codegen* cg = cu->cg.get(); |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 79 | LIR* this_lir; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 80 | |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 81 | if (head_lir == tail_lir) return; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 82 | |
buzbee | 28c9a83 | 2012-11-21 15:39:13 -0800 | [diff] [blame] | 83 | for (this_lir = PREV_LIR(tail_lir); this_lir != head_lir; this_lir = PREV_LIR(this_lir)) { |
buzbee | 4ef3e45 | 2012-12-14 13:35:28 -0800 | [diff] [blame] | 84 | |
| 85 | if (is_pseudo_opcode(this_lir->opcode)) continue; |
| 86 | |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 87 | int sink_distance = 0; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 88 | |
buzbee | 4ef3e45 | 2012-12-14 13:35:28 -0800 | [diff] [blame] | 89 | uint64_t target_flags = cg->GetTargetInstFlags(this_lir->opcode); |
| 90 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 91 | /* Skip non-interesting instructions */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 92 | if ((this_lir->flags.is_nop == true) || |
buzbee | 4ef3e45 | 2012-12-14 13:35:28 -0800 | [diff] [blame] | 93 | (target_flags & IS_BRANCH) || |
| 94 | ((target_flags & (REG_DEF0 | REG_DEF1)) == (REG_DEF0 | REG_DEF1)) || // Skip wide loads. |
| 95 | ((target_flags & (REG_USE0 | REG_USE1 | REG_USE2)) == |
| 96 | (REG_USE0 | REG_USE1 | REG_USE2)) || // Skip wide stores. |
| 97 | !(target_flags & (IS_LOAD | IS_STORE))) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 98 | continue; |
| 99 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 100 | |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 101 | int native_reg_id; |
| 102 | if (cu->instruction_set == kX86) { |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 103 | // If x86, location differs depending on whether memory/reg operation. |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 104 | native_reg_id = (cg->GetTargetInstFlags(this_lir->opcode) & IS_STORE) ? this_lir->operands[2] |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 105 | : this_lir->operands[0]; |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 106 | } else { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 107 | native_reg_id = this_lir->operands[0]; |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 108 | } |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 109 | bool is_this_lir_load = cg->GetTargetInstFlags(this_lir->opcode) & IS_LOAD; |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 110 | LIR* check_lir; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 111 | /* Use the mem mask to determine the rough memory location */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 112 | uint64_t this_mem_mask = (this_lir->use_mask | this_lir->def_mask) & ENCODE_MEM; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 113 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 114 | /* |
| 115 | * Currently only eliminate redundant ld/st for constant and Dalvik |
| 116 | * register accesses. |
| 117 | */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 118 | if (!(this_mem_mask & (ENCODE_LITERAL | ENCODE_DALVIK_REG))) continue; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 119 | |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 120 | uint64_t stop_def_reg_mask = this_lir->def_mask & ~ENCODE_MEM; |
| 121 | uint64_t stop_use_reg_mask; |
| 122 | if (cu->instruction_set == kX86) { |
| 123 | stop_use_reg_mask = (IS_BRANCH | this_lir->use_mask) & ~ENCODE_MEM; |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 124 | } else { |
| 125 | /* |
| 126 | * Add pc to the resource mask to prevent this instruction |
| 127 | * from sinking past branch instructions. Also take out the memory |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 128 | * region bits since stop_mask is used to check data/control |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 129 | * dependencies. |
| 130 | */ |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 131 | stop_use_reg_mask = (cg->GetPCUseDefEncoding() | this_lir->use_mask) & ~ENCODE_MEM; |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 132 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 133 | |
buzbee | 28c9a83 | 2012-11-21 15:39:13 -0800 | [diff] [blame] | 134 | for (check_lir = NEXT_LIR(this_lir); check_lir != tail_lir; check_lir = NEXT_LIR(check_lir)) { |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 135 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 136 | /* |
| 137 | * Skip already dead instructions (whose dataflow information is |
| 138 | * outdated and misleading). |
| 139 | */ |
buzbee | 4ef3e45 | 2012-12-14 13:35:28 -0800 | [diff] [blame] | 140 | if (check_lir->flags.is_nop || is_pseudo_opcode(check_lir->opcode)) continue; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 141 | |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 142 | uint64_t check_mem_mask = (check_lir->use_mask | check_lir->def_mask) & ENCODE_MEM; |
| 143 | uint64_t alias_condition = this_mem_mask & check_mem_mask; |
| 144 | bool stop_here = false; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 145 | |
| 146 | /* |
| 147 | * Potential aliases seen - check the alias relations |
| 148 | */ |
buzbee | 4ef3e45 | 2012-12-14 13:35:28 -0800 | [diff] [blame] | 149 | uint64_t check_flags = cg->GetTargetInstFlags(check_lir->opcode); |
| 150 | // TUNING: Support instructions with multiple register targets. |
| 151 | if ((check_flags & (REG_DEF0 | REG_DEF1)) == (REG_DEF0 | REG_DEF1)) { |
| 152 | stop_here = true; |
| 153 | } else if (check_mem_mask != ENCODE_MEM && alias_condition != 0) { |
| 154 | bool is_check_lir_load = check_flags & IS_LOAD; |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 155 | if (alias_condition == ENCODE_LITERAL) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 156 | /* |
| 157 | * Should only see literal loads in the instruction |
| 158 | * stream. |
| 159 | */ |
buzbee | 4ef3e45 | 2012-12-14 13:35:28 -0800 | [diff] [blame] | 160 | DCHECK(!(check_flags & IS_STORE)); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 161 | /* Same value && same register type */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 162 | if (check_lir->alias_info == this_lir->alias_info && |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 163 | cg->SameRegType(check_lir->operands[0], native_reg_id)) { |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 164 | /* |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 165 | * Different destination register - insert |
| 166 | * a move |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 167 | */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 168 | if (check_lir->operands[0] != native_reg_id) { |
| 169 | ConvertMemOpIntoMove(cu, check_lir, check_lir->operands[0], |
| 170 | native_reg_id); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 171 | } |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 172 | check_lir->flags.is_nop = true; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 173 | } |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 174 | } else if (alias_condition == ENCODE_DALVIK_REG) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 175 | /* Must alias */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 176 | if (check_lir->alias_info == this_lir->alias_info) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 177 | /* Only optimize compatible registers */ |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 178 | bool reg_compatible = cg->SameRegType(check_lir->operands[0], native_reg_id); |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 179 | if ((is_this_lir_load && is_check_lir_load) || |
| 180 | (!is_this_lir_load && is_check_lir_load)) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 181 | /* RAR or RAW */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 182 | if (reg_compatible) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 183 | /* |
| 184 | * Different destination register - |
| 185 | * insert a move |
| 186 | */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 187 | if (check_lir->operands[0] != |
| 188 | native_reg_id) { |
| 189 | ConvertMemOpIntoMove(cu, check_lir, check_lir->operands[0], |
| 190 | native_reg_id); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 191 | } |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 192 | check_lir->flags.is_nop = true; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 193 | } else { |
| 194 | /* |
| 195 | * Destinaions are of different types - |
| 196 | * something complicated going on so |
| 197 | * stop looking now. |
| 198 | */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 199 | stop_here = true; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 200 | } |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 201 | } else if (is_this_lir_load && !is_check_lir_load) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 202 | /* WAR - register value is killed */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 203 | stop_here = true; |
| 204 | } else if (!is_this_lir_load && !is_check_lir_load) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 205 | /* WAW - nuke the earlier store */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 206 | this_lir->flags.is_nop = true; |
| 207 | stop_here = true; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 208 | } |
| 209 | /* Partial overlap */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 210 | } else if (IsDalvikRegisterClobbered(this_lir, check_lir)) { |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 211 | /* |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 212 | * It is actually ok to continue if check_lir |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 213 | * is a read. But it is hard to make a test |
| 214 | * case for this so we just stop here to be |
| 215 | * conservative. |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 216 | */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 217 | stop_here = true; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 218 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 219 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 220 | /* Memory content may be updated. Stop looking now. */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 221 | if (stop_here) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 222 | break; |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 223 | /* The check_lir has been transformed - check the next one */ |
| 224 | } else if (check_lir->flags.is_nop) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 225 | continue; |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | |
| 230 | /* |
| 231 | * this and check LIRs have no memory dependency. Now check if |
| 232 | * their register operands have any RAW, WAR, and WAW |
| 233 | * dependencies. If so, stop looking. |
| 234 | */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 235 | if (stop_here == false) { |
| 236 | stop_here = CHECK_REG_DEP(stop_use_reg_mask, stop_def_reg_mask, check_lir); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 237 | } |
| 238 | |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 239 | if (stop_here == true) { |
| 240 | if (cu->instruction_set == kX86) { |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 241 | // Prevent stores from being sunk between ops that generate ccodes and |
| 242 | // ops that use them. |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 243 | uint64_t flags = cg->GetTargetInstFlags(check_lir->opcode); |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 244 | if (sink_distance > 0 && (flags & IS_BRANCH) && (flags & USES_CCODES)) { |
| 245 | check_lir = PREV_LIR(check_lir); |
| 246 | sink_distance--; |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 247 | } |
jeffhao | 573b429 | 2012-07-30 16:37:41 -0700 | [diff] [blame] | 248 | } |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 249 | DEBUG_OPT(dump_dependent_insn_pair(this_lir, check_lir, "REG CLOBBERED")); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 250 | /* Only sink store instructions */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 251 | if (sink_distance && !is_this_lir_load) { |
| 252 | LIR* new_store_lir = static_cast<LIR*>(NewMem(cu, sizeof(LIR), true, kAllocLIR)); |
| 253 | *new_store_lir = *this_lir; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 254 | /* |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 255 | * Stop point found - insert *before* the check_lir |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 256 | * since the instruction list is scanned in the |
| 257 | * top-down order. |
| 258 | */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 259 | InsertLIRBefore(check_lir, new_store_lir); |
| 260 | this_lir->flags.is_nop = true; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 261 | } |
| 262 | break; |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 263 | } else if (!check_lir->flags.is_nop) { |
| 264 | sink_distance++; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 265 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 266 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 267 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | /* |
| 271 | * Perform a pass of bottom-up walk, from the second instruction in the |
| 272 | * superblock, to try to hoist loads to earlier slots. |
| 273 | */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 274 | void ApplyLoadHoisting(CompilationUnit* cu, LIR* head_lir, LIR* tail_lir) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 275 | { |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 276 | Codegen* cg = cu->cg.get(); |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 277 | LIR* this_lir, *check_lir; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 278 | /* |
| 279 | * Store the list of independent instructions that can be hoisted past. |
| 280 | * Will decide the best place to insert later. |
| 281 | */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 282 | LIR* prev_inst_list[MAX_HOIST_DISTANCE]; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 283 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 284 | /* Empty block */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 285 | if (head_lir == tail_lir) return; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 286 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 287 | /* Start from the second instruction */ |
buzbee | 28c9a83 | 2012-11-21 15:39:13 -0800 | [diff] [blame] | 288 | for (this_lir = NEXT_LIR(head_lir); this_lir != tail_lir; this_lir = NEXT_LIR(this_lir)) { |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 289 | |
buzbee | 4ef3e45 | 2012-12-14 13:35:28 -0800 | [diff] [blame] | 290 | if (is_pseudo_opcode(this_lir->opcode)) continue; |
| 291 | |
| 292 | uint64_t target_flags = cg->GetTargetInstFlags(this_lir->opcode); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 293 | /* Skip non-interesting instructions */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 294 | if ((this_lir->flags.is_nop == true) || |
buzbee | 4ef3e45 | 2012-12-14 13:35:28 -0800 | [diff] [blame] | 295 | ((target_flags & (REG_DEF0 | REG_DEF1)) == (REG_DEF0 | REG_DEF1)) || |
| 296 | !(target_flags & IS_LOAD)) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 297 | continue; |
| 298 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 299 | |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 300 | uint64_t stop_use_all_mask = this_lir->use_mask; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 301 | |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 302 | if (cu->instruction_set != kX86) { |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 303 | /* |
| 304 | * Branches for null/range checks are marked with the true resource |
| 305 | * bits, and loads to Dalvik registers, constant pools, and non-alias |
| 306 | * locations are safe to be hoisted. So only mark the heap references |
| 307 | * conservatively here. |
| 308 | */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 309 | if (stop_use_all_mask & ENCODE_HEAP_REF) { |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 310 | stop_use_all_mask |= cg->GetPCUseDefEncoding(); |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 311 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 312 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 313 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 314 | /* Similar as above, but just check for pure register dependency */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 315 | uint64_t stop_use_reg_mask = stop_use_all_mask & ~ENCODE_MEM; |
| 316 | uint64_t stop_def_reg_mask = this_lir->def_mask & ~ENCODE_MEM; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 317 | |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 318 | int next_slot = 0; |
| 319 | bool stop_here = false; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 320 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 321 | /* Try to hoist the load to a good spot */ |
buzbee | 28c9a83 | 2012-11-21 15:39:13 -0800 | [diff] [blame] | 322 | for (check_lir = PREV_LIR(this_lir); check_lir != head_lir; check_lir = PREV_LIR(check_lir)) { |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 323 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 324 | /* |
| 325 | * Skip already dead instructions (whose dataflow information is |
| 326 | * outdated and misleading). |
| 327 | */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 328 | if (check_lir->flags.is_nop) continue; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 329 | |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 330 | uint64_t check_mem_mask = check_lir->def_mask & ENCODE_MEM; |
| 331 | uint64_t alias_condition = stop_use_all_mask & check_mem_mask; |
| 332 | stop_here = false; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 333 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 334 | /* Potential WAR alias seen - check the exact relation */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 335 | if (check_mem_mask != ENCODE_MEM && alias_condition != 0) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 336 | /* We can fully disambiguate Dalvik references */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 337 | if (alias_condition == ENCODE_DALVIK_REG) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 338 | /* Must alias or partually overlap */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 339 | if ((check_lir->alias_info == this_lir->alias_info) || |
| 340 | IsDalvikRegisterClobbered(this_lir, check_lir)) { |
| 341 | stop_here = true; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 342 | } |
| 343 | /* Conservatively treat all heap refs as may-alias */ |
| 344 | } else { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 345 | DCHECK_EQ(alias_condition, ENCODE_HEAP_REF); |
| 346 | stop_here = true; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 347 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 348 | /* Memory content may be updated. Stop looking now. */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 349 | if (stop_here) { |
| 350 | prev_inst_list[next_slot++] = check_lir; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 351 | break; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 352 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 353 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 354 | |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 355 | if (stop_here == false) { |
| 356 | stop_here = CHECK_REG_DEP(stop_use_reg_mask, stop_def_reg_mask, |
| 357 | check_lir); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 358 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 359 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 360 | /* |
| 361 | * Store the dependent or non-pseudo/indepedent instruction to the |
| 362 | * list. |
| 363 | */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 364 | if (stop_here || !is_pseudo_opcode(check_lir->opcode)) { |
| 365 | prev_inst_list[next_slot++] = check_lir; |
| 366 | if (next_slot == MAX_HOIST_DISTANCE) break; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 367 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 368 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 369 | /* Found a new place to put the load - move it here */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 370 | if (stop_here == true) { |
| 371 | DEBUG_OPT(dump_dependent_insn_pair(check_lir, this_lir "HOIST STOP")); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 372 | break; |
| 373 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 374 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 375 | |
| 376 | /* |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 377 | * Reached the top - use head_lir as the dependent marker as all labels |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 378 | * are barriers. |
| 379 | */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 380 | if (stop_here == false && next_slot < MAX_HOIST_DISTANCE) { |
| 381 | prev_inst_list[next_slot++] = head_lir; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 382 | } |
| 383 | |
| 384 | /* |
| 385 | * At least one independent instruction is found. Scan in the reversed |
| 386 | * direction to find a beneficial slot. |
| 387 | */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 388 | if (next_slot >= 2) { |
| 389 | int first_slot = next_slot - 2; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 390 | int slot; |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 391 | LIR* dep_lir = prev_inst_list[next_slot-1]; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 392 | /* If there is ld-ld dependency, wait LDLD_DISTANCE cycles */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 393 | if (!is_pseudo_opcode(dep_lir->opcode) && |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 394 | (cg->GetTargetInstFlags(dep_lir->opcode) & IS_LOAD)) { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 395 | first_slot -= LDLD_DISTANCE; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 396 | } |
| 397 | /* |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 398 | * Make sure we check slot >= 0 since first_slot may be negative |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 399 | * when the loop is first entered. |
| 400 | */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 401 | for (slot = first_slot; slot >= 0; slot--) { |
| 402 | LIR* cur_lir = prev_inst_list[slot]; |
| 403 | LIR* prev_lir = prev_inst_list[slot+1]; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 404 | |
| 405 | /* Check the highest instruction */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 406 | if (prev_lir->def_mask == ENCODE_ALL) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 407 | /* |
| 408 | * If the first instruction is a load, don't hoist anything |
| 409 | * above it since it is unlikely to be beneficial. |
| 410 | */ |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 411 | if (cg->GetTargetInstFlags(cur_lir->opcode) & IS_LOAD) continue; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 412 | /* |
| 413 | * If the remaining number of slots is less than LD_LATENCY, |
| 414 | * insert the hoisted load here. |
| 415 | */ |
| 416 | if (slot < LD_LATENCY) break; |
| 417 | } |
| 418 | |
buzbee | 8320f38 | 2012-09-11 16:29:42 -0700 | [diff] [blame] | 419 | // Don't look across a barrier label |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 420 | if ((prev_lir->opcode == kPseudoTargetLabel) || |
| 421 | (prev_lir->opcode == kPseudoSafepointPC) || |
| 422 | (prev_lir->opcode == kPseudoBarrier)) { |
buzbee | 8320f38 | 2012-09-11 16:29:42 -0700 | [diff] [blame] | 423 | break; |
| 424 | } |
| 425 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 426 | /* |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 427 | * Try to find two instructions with load/use dependency until |
| 428 | * the remaining instructions are less than LD_LATENCY. |
| 429 | */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 430 | bool prev_is_load = is_pseudo_opcode(prev_lir->opcode) ? false : |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 431 | (cg->GetTargetInstFlags(prev_lir->opcode) & IS_LOAD); |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 432 | if (((cur_lir->use_mask & prev_lir->def_mask) && prev_is_load) || (slot < LD_LATENCY)) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 433 | break; |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | /* Found a slot to hoist to */ |
| 438 | if (slot >= 0) { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 439 | LIR* cur_lir = prev_inst_list[slot]; |
| 440 | LIR* new_load_lir = static_cast<LIR*>(NewMem(cu, sizeof(LIR), true, kAllocLIR)); |
| 441 | *new_load_lir = *this_lir; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 442 | /* |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 443 | * Insertion is guaranteed to succeed since check_lir |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 444 | * is never the first LIR on the list |
| 445 | */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 446 | InsertLIRBefore(cur_lir, new_load_lir); |
| 447 | this_lir->flags.is_nop = true; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 448 | } |
| 449 | } |
| 450 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 451 | } |
| 452 | |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 453 | void ApplyLocalOptimizations(CompilationUnit* cu, LIR* head_lir, |
| 454 | LIR* tail_lir) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 455 | { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 456 | if (!(cu->disable_opt & (1 << kLoadStoreElimination))) { |
| 457 | ApplyLoadStoreElimination(cu, head_lir, tail_lir); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 458 | } |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 459 | if (!(cu->disable_opt & (1 << kLoadHoisting))) { |
| 460 | ApplyLoadHoisting(cu, head_lir, tail_lir); |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 461 | } |
| 462 | } |
| 463 | |
| 464 | /* |
| 465 | * Nop any unconditional branches that go to the next instruction. |
| 466 | * Note: new redundant branches may be inserted later, and we'll |
| 467 | * use a check in final instruction assembly to nop those out. |
| 468 | */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 469 | void RemoveRedundantBranches(CompilationUnit* cu) |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 470 | { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 471 | LIR* this_lir; |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 472 | Codegen* cg = cu->cg.get(); |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 473 | |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 474 | for (this_lir = cu->first_lir_insn; this_lir != cu->last_lir_insn; this_lir = NEXT_LIR(this_lir)) { |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 475 | |
| 476 | /* Branch to the next instruction */ |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 477 | if (cg->IsUnconditionalBranch(this_lir)) { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 478 | LIR* next_lir = this_lir; |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 479 | |
| 480 | while (true) { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 481 | next_lir = NEXT_LIR(next_lir); |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 482 | |
| 483 | /* |
| 484 | * Is the branch target the next instruction? |
| 485 | */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 486 | if (next_lir == this_lir->target) { |
| 487 | this_lir->flags.is_nop = true; |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 488 | break; |
| 489 | } |
| 490 | |
| 491 | /* |
| 492 | * Found real useful stuff between the branch and the target. |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 493 | * Need to explicitly check the last_lir_insn here because it |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 494 | * might be the last real instruction. |
| 495 | */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 496 | if (!is_pseudo_opcode(next_lir->opcode) || |
| 497 | (next_lir == cu->last_lir_insn)) |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 498 | break; |
| 499 | } |
| 500 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 501 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 502 | } |
Elliott Hughes | 11d1b0c | 2012-01-23 16:57:47 -0800 | [diff] [blame] | 503 | |
| 504 | } // namespace art |