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

Side by Side Diff: src/x64/lithium-codegen-x64.cc

Issue 6701003: X64: Port optimization of LMulI to x64. (Closed)
Patch Set: Reuse can_overflow variable. Created 9 years, 9 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 | « no previous file | 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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 857
858 858
859 void LCodeGen::DoMulI(LMulI* instr) { 859 void LCodeGen::DoMulI(LMulI* instr) {
860 Register left = ToRegister(instr->InputAt(0)); 860 Register left = ToRegister(instr->InputAt(0));
861 LOperand* right = instr->InputAt(1); 861 LOperand* right = instr->InputAt(1);
862 862
863 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { 863 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
864 __ movl(kScratchRegister, left); 864 __ movl(kScratchRegister, left);
865 } 865 }
866 866
867 bool can_overflow =
868 instr->hydrogen()->CheckFlag(HValue::kCanOverflow);
867 if (right->IsConstantOperand()) { 869 if (right->IsConstantOperand()) {
868 int right_value = ToInteger32(LConstantOperand::cast(right)); 870 int right_value = ToInteger32(LConstantOperand::cast(right));
869 __ imull(left, left, Immediate(right_value)); 871 if (right_value == -1) {
872 __ negl(left);
873 } else if (right_value == 0) {
William Hesse 2011/03/17 12:55:06 If BailoutOnMinusZero is true, we always bail out
Lasse Reichstein 2011/03/17 18:11:55 Yes, I noticed too that we bail out even if we don
874 __ xorl(left, left);
875 } else if (right_value == 2) {
876 __ addl(left, left);
877 } else if (!can_overflow) {
878 // If the multiplication is known to not overflow, we
879 // can use operations that don't set the overflow flag
880 // correctly.
881 switch (right_value) {
882 case 1:
883 // Do nothing.
884 break;
885 case 3:
886 __ leal(left, Operand(left, left, times_2, 0));
887 break;
888 case 4:
889 __ shll(left, Immediate(2));
890 break;
891 case 5:
892 __ leal(left, Operand(left, left, times_4, 0));
893 break;
894 case 8:
895 __ shll(left, Immediate(3));
896 break;
897 case 9:
898 __ leal(left, Operand(left, left, times_8, 0));
899 break;
900 case 16:
901 __ shll(left, Immediate(4));
902 break;
903 default:
904 __ imull(left, left, Immediate(right_value));
905 break;
906 }
907 } else {
908 __ imull(left, left, Immediate(right_value));
909 }
870 } else if (right->IsStackSlot()) { 910 } else if (right->IsStackSlot()) {
871 __ imull(left, ToOperand(right)); 911 __ imull(left, ToOperand(right));
872 } else { 912 } else {
873 __ imull(left, ToRegister(right)); 913 __ imull(left, ToRegister(right));
874 } 914 }
875 915
876 if (instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) { 916 if (can_overflow) {
877 DeoptimizeIf(overflow, instr->environment()); 917 DeoptimizeIf(overflow, instr->environment());
878 } 918 }
879 919
880 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { 920 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
881 // Bail out if the result is supposed to be negative zero. 921 // Bail out if the result is supposed to be negative zero.
882 NearLabel done; 922 NearLabel done;
883 __ testl(left, left); 923 __ testl(left, left);
884 __ j(not_zero, &done); 924 __ j(not_zero, &done);
885 if (right->IsConstantOperand()) { 925 if (right->IsConstantOperand()) {
886 if (ToInteger32(LConstantOperand::cast(right)) <= 0) { 926 if (ToInteger32(LConstantOperand::cast(right)) <= 0) {
(...skipping 2891 matching lines...) Expand 10 before | Expand all | Expand 10 after
3778 RegisterEnvironmentForDeoptimization(environment); 3818 RegisterEnvironmentForDeoptimization(environment);
3779 ASSERT(osr_pc_offset_ == -1); 3819 ASSERT(osr_pc_offset_ == -1);
3780 osr_pc_offset_ = masm()->pc_offset(); 3820 osr_pc_offset_ = masm()->pc_offset();
3781 } 3821 }
3782 3822
3783 #undef __ 3823 #undef __
3784 3824
3785 } } // namespace v8::internal 3825 } } // namespace v8::internal
3786 3826
3787 #endif // V8_TARGET_ARCH_X64 3827 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698