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

Side by Side Diff: src/compiler/x64/code-generator-x64.cc

Issue 2418803002: [turbofan]: Micro optimizations to lea[l/q] on ia32/x64 (Closed)
Patch Set: Fix syntax error Created 4 years, 2 months 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
« no previous file with comments | « src/compiler/ia32/code-generator-ia32.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 "src/compiler/code-generator.h" 5 #include "src/compiler/code-generator.h"
6 6
7 #include "src/compilation-info.h" 7 #include "src/compilation-info.h"
8 #include "src/compiler/code-generator-impl.h" 8 #include "src/compiler/code-generator-impl.h"
9 #include "src/compiler/gap-resolver.h" 9 #include "src/compiler/gap-resolver.h"
10 #include "src/compiler/node-matchers.h" 10 #include "src/compiler/node-matchers.h"
(...skipping 1979 matching lines...) Expand 10 before | Expand all | Expand 10 after
1990 int32_t constant_summand = i.InputInt32(1); 1990 int32_t constant_summand = i.InputInt32(1);
1991 if (constant_summand > 0) { 1991 if (constant_summand > 0) {
1992 __ addl(i.OutputRegister(), Immediate(constant_summand)); 1992 __ addl(i.OutputRegister(), Immediate(constant_summand));
1993 } else if (constant_summand < 0) { 1993 } else if (constant_summand < 0) {
1994 __ subl(i.OutputRegister(), Immediate(-constant_summand)); 1994 __ subl(i.OutputRegister(), Immediate(-constant_summand));
1995 } 1995 }
1996 } else if (mode == kMode_MR1) { 1996 } else if (mode == kMode_MR1) {
1997 if (i.InputRegister(1).is(i.OutputRegister())) { 1997 if (i.InputRegister(1).is(i.OutputRegister())) {
1998 __ shll(i.OutputRegister(), Immediate(1)); 1998 __ shll(i.OutputRegister(), Immediate(1));
1999 } else { 1999 } else {
2000 __ leal(i.OutputRegister(), i.MemoryOperand()); 2000 __ addl(i.OutputRegister(), i.InputRegister(1));
2001 } 2001 }
2002 } else if (mode == kMode_M2) { 2002 } else if (mode == kMode_M2) {
2003 __ shll(i.OutputRegister(), Immediate(1)); 2003 __ shll(i.OutputRegister(), Immediate(1));
2004 } else if (mode == kMode_M4) { 2004 } else if (mode == kMode_M4) {
2005 __ shll(i.OutputRegister(), Immediate(2)); 2005 __ shll(i.OutputRegister(), Immediate(2));
2006 } else if (mode == kMode_M8) { 2006 } else if (mode == kMode_M8) {
2007 __ shll(i.OutputRegister(), Immediate(3)); 2007 __ shll(i.OutputRegister(), Immediate(3));
2008 } else { 2008 } else {
2009 __ leal(i.OutputRegister(), i.MemoryOperand()); 2009 __ leal(i.OutputRegister(), i.MemoryOperand());
2010 } 2010 }
2011 } else if (mode == kMode_MR1 &&
2012 i.InputRegister(1).is(i.OutputRegister())) {
2013 __ addl(i.OutputRegister(), i.InputRegister(0));
2011 } else { 2014 } else {
2012 __ leal(i.OutputRegister(), i.MemoryOperand()); 2015 __ leal(i.OutputRegister(), i.MemoryOperand());
2013 } 2016 }
2014 __ AssertZeroExtended(i.OutputRegister()); 2017 __ AssertZeroExtended(i.OutputRegister());
2015 break; 2018 break;
2016 } 2019 }
2017 case kX64Lea: 2020 case kX64Lea: {
2018 __ leaq(i.OutputRegister(), i.MemoryOperand()); 2021 AddressingMode mode = AddressingModeField::decode(instr->opcode());
2022 // Shorten "leaq" to "addq", "subq" or "shlq" if the register allocation
2023 // and addressing mode just happens to work out. The "addq"/"subq" forms
2024 // in these cases are faster based on measurements.
2025 if (i.InputRegister(0).is(i.OutputRegister())) {
2026 if (mode == kMode_MRI) {
2027 int32_t constant_summand = i.InputInt32(1);
2028 if (constant_summand > 0) {
2029 __ addq(i.OutputRegister(), Immediate(constant_summand));
2030 } else if (constant_summand < 0) {
2031 __ subq(i.OutputRegister(), Immediate(-constant_summand));
2032 }
2033 } else if (mode == kMode_MR1) {
2034 if (i.InputRegister(1).is(i.OutputRegister())) {
2035 __ shlq(i.OutputRegister(), Immediate(1));
2036 } else {
2037 __ addq(i.OutputRegister(), i.InputRegister(1));
2038 }
2039 } else if (mode == kMode_M2) {
2040 __ shlq(i.OutputRegister(), Immediate(1));
2041 } else if (mode == kMode_M4) {
2042 __ shlq(i.OutputRegister(), Immediate(2));
2043 } else if (mode == kMode_M8) {
2044 __ shlq(i.OutputRegister(), Immediate(3));
2045 } else {
2046 __ leaq(i.OutputRegister(), i.MemoryOperand());
2047 }
2048 } else if (mode == kMode_MR1 &&
2049 i.InputRegister(1).is(i.OutputRegister())) {
2050 __ addq(i.OutputRegister(), i.InputRegister(0));
2051 } else {
2052 __ leaq(i.OutputRegister(), i.MemoryOperand());
2053 }
2019 break; 2054 break;
2055 }
2020 case kX64Dec32: 2056 case kX64Dec32:
2021 __ decl(i.OutputRegister()); 2057 __ decl(i.OutputRegister());
2022 break; 2058 break;
2023 case kX64Inc32: 2059 case kX64Inc32:
2024 __ incl(i.OutputRegister()); 2060 __ incl(i.OutputRegister());
2025 break; 2061 break;
2026 case kX64Push: 2062 case kX64Push:
2027 if (HasImmediateInput(instr, 0)) { 2063 if (HasImmediateInput(instr, 0)) {
2028 __ pushq(i.InputImmediate(0)); 2064 __ pushq(i.InputImmediate(0));
2029 frame_access_state()->IncreaseSPDelta(1); 2065 frame_access_state()->IncreaseSPDelta(1);
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
2720 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; 2756 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc;
2721 __ Nop(padding_size); 2757 __ Nop(padding_size);
2722 } 2758 }
2723 } 2759 }
2724 2760
2725 #undef __ 2761 #undef __
2726 2762
2727 } // namespace compiler 2763 } // namespace compiler
2728 } // namespace internal 2764 } // namespace internal
2729 } // namespace v8 2765 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/ia32/code-generator-ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698