Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: src/mips/macro-assembler-mips.cc

Issue 700873002: MIPS: Improve compare and branch combining. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/compiler/mips/instruction-selector-mips.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <limits.h> // For LONG_MIN, LONG_MAX. 5 #include <limits.h> // For LONG_MIN, LONG_MAX.
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #if V8_TARGET_ARCH_MIPS 9 #if V8_TARGET_ARCH_MIPS
10 10
(...skipping 2019 matching lines...) Expand 10 before | Expand all | Expand 10 after
2030 } else { 2030 } else {
2031 // Be careful to always use shifted_branch_offset only just before the 2031 // Be careful to always use shifted_branch_offset only just before the
2032 // branch instruction, as the location will be remember for patching the 2032 // branch instruction, as the location will be remember for patching the
2033 // target. 2033 // target.
2034 BlockTrampolinePoolScope block_trampoline_pool(this); 2034 BlockTrampolinePoolScope block_trampoline_pool(this);
2035 switch (cond) { 2035 switch (cond) {
2036 case cc_always: 2036 case cc_always:
2037 b(offset); 2037 b(offset);
2038 break; 2038 break;
2039 case eq: 2039 case eq:
2040 // We don't want any other register but scratch clobbered. 2040 if (rt.imm32_ == 0) {
2041 DCHECK(!scratch.is(rs)); 2041 beq(rs, zero_reg, offset);
2042 r2 = scratch; 2042 } else {
2043 li(r2, rt); 2043 // We don't want any other register but scratch clobbered.
2044 beq(rs, r2, offset); 2044 DCHECK(!scratch.is(rs));
2045 r2 = scratch;
2046 li(r2, rt);
2047 beq(rs, r2, offset);
2048 }
2045 break; 2049 break;
2046 case ne: 2050 case ne:
2047 // We don't want any other register but scratch clobbered. 2051 if (rt.imm32_ == 0) {
2048 DCHECK(!scratch.is(rs)); 2052 bne(rs, zero_reg, offset);
2049 r2 = scratch; 2053 } else {
2050 li(r2, rt); 2054 // We don't want any other register but scratch clobbered.
2051 bne(rs, r2, offset); 2055 DCHECK(!scratch.is(rs));
2056 r2 = scratch;
2057 li(r2, rt);
2058 bne(rs, r2, offset);
2059 }
2052 break; 2060 break;
2053 // Signed comparison. 2061 // Signed comparison.
2054 case greater: 2062 case greater:
2055 if (rt.imm32_ == 0) { 2063 if (rt.imm32_ == 0) {
2056 bgtz(rs, offset); 2064 bgtz(rs, offset);
2057 } else { 2065 } else {
2058 r2 = scratch; 2066 r2 = scratch;
2059 li(r2, rt); 2067 li(r2, rt);
2060 slt(scratch, r2, rs); 2068 slt(scratch, r2, rs);
2061 bne(scratch, zero_reg, offset); 2069 bne(scratch, zero_reg, offset);
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
2283 // Be careful to always use shifted_branch_offset only just before the 2291 // Be careful to always use shifted_branch_offset only just before the
2284 // branch instruction, as the location will be remember for patching the 2292 // branch instruction, as the location will be remember for patching the
2285 // target. 2293 // target.
2286 BlockTrampolinePoolScope block_trampoline_pool(this); 2294 BlockTrampolinePoolScope block_trampoline_pool(this);
2287 switch (cond) { 2295 switch (cond) {
2288 case cc_always: 2296 case cc_always:
2289 offset = shifted_branch_offset(L, false); 2297 offset = shifted_branch_offset(L, false);
2290 b(offset); 2298 b(offset);
2291 break; 2299 break;
2292 case eq: 2300 case eq:
2293 DCHECK(!scratch.is(rs)); 2301 if (rt.imm32_ == 0) {
2294 r2 = scratch; 2302 offset = shifted_branch_offset(L, false);
2295 li(r2, rt); 2303 beq(rs, zero_reg, offset);
2296 offset = shifted_branch_offset(L, false); 2304 } else {
2297 beq(rs, r2, offset); 2305 DCHECK(!scratch.is(rs));
2306 r2 = scratch;
2307 li(r2, rt);
2308 offset = shifted_branch_offset(L, false);
2309 beq(rs, r2, offset);
2310 }
2298 break; 2311 break;
2299 case ne: 2312 case ne:
2300 DCHECK(!scratch.is(rs)); 2313 if (rt.imm32_ == 0) {
2301 r2 = scratch; 2314 offset = shifted_branch_offset(L, false);
2302 li(r2, rt); 2315 bne(rs, zero_reg, offset);
2303 offset = shifted_branch_offset(L, false); 2316 } else {
2304 bne(rs, r2, offset); 2317 DCHECK(!scratch.is(rs));
2318 r2 = scratch;
2319 li(r2, rt);
2320 offset = shifted_branch_offset(L, false);
2321 bne(rs, r2, offset);
2322 }
2305 break; 2323 break;
2306 // Signed comparison. 2324 // Signed comparison.
2307 case greater: 2325 case greater:
2308 if (rt.imm32_ == 0) { 2326 if (rt.imm32_ == 0) {
2309 offset = shifted_branch_offset(L, false); 2327 offset = shifted_branch_offset(L, false);
2310 bgtz(rs, offset); 2328 bgtz(rs, offset);
2311 } else { 2329 } else {
2312 DCHECK(!scratch.is(rs)); 2330 DCHECK(!scratch.is(rs));
2313 r2 = scratch; 2331 r2 = scratch;
2314 li(r2, rt); 2332 li(r2, rt);
(...skipping 3929 matching lines...) Expand 10 before | Expand all | Expand 10 after
6244 } 6262 }
6245 if (mag.shift > 0) sra(result, result, mag.shift); 6263 if (mag.shift > 0) sra(result, result, mag.shift);
6246 srl(at, dividend, 31); 6264 srl(at, dividend, 31);
6247 Addu(result, result, Operand(at)); 6265 Addu(result, result, Operand(at));
6248 } 6266 }
6249 6267
6250 6268
6251 } } // namespace v8::internal 6269 } } // namespace v8::internal
6252 6270
6253 #endif // V8_TARGET_ARCH_MIPS 6271 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/compiler/mips/instruction-selector-mips.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698