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

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

Issue 227553003: Fixed flooring division by -1 on ARM. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « src/ia32/lithium-codegen-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 // 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 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 // If the divisor is positive, things are easy: There can be no deopts and we 1132 // If the divisor is positive, things are easy: There can be no deopts and we
1133 // can simply do an arithmetic right shift. 1133 // can simply do an arithmetic right shift.
1134 if (divisor == 1) return; 1134 if (divisor == 1) return;
1135 int32_t shift = WhichPowerOf2Abs(divisor); 1135 int32_t shift = WhichPowerOf2Abs(divisor);
1136 if (divisor > 1) { 1136 if (divisor > 1) {
1137 __ sarl(dividend, Immediate(shift)); 1137 __ sarl(dividend, Immediate(shift));
1138 return; 1138 return;
1139 } 1139 }
1140 1140
1141 // If the divisor is negative, we have to negate and handle edge cases. 1141 // If the divisor is negative, we have to negate and handle edge cases.
1142 Label not_kmin_int, done;
1143 __ negl(dividend); 1142 __ negl(dividend);
1144 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { 1143 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
1145 DeoptimizeIf(zero, instr->environment()); 1144 DeoptimizeIf(zero, instr->environment());
1146 } 1145 }
1147 if (instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) { 1146
1148 // Note that we could emit branch-free code, but that would need one more 1147 // If the negation could not overflow, simply shifting is OK.
1149 // register. 1148 if (!instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) {
1150 __ j(no_overflow, &not_kmin_int, Label::kNear); 1149 __ sarl(dividend, Immediate(shift));
1151 if (divisor == -1) { 1150 return;
1152 DeoptimizeIf(no_condition, instr->environment());
1153 } else {
1154 __ movl(dividend, Immediate(kMinInt / divisor));
1155 __ jmp(&done, Label::kNear);
1156 }
1157 } 1151 }
1152
1153 // Note that we could emit branch-free code, but that would need one more
1154 // register.
1155 if (divisor == -1) {
1156 DeoptimizeIf(overflow, instr->environment());
1157 return;
1158 }
1159
1160 Label not_kmin_int, done;
1161 __ j(no_overflow, &not_kmin_int, Label::kNear);
1162 __ movl(dividend, Immediate(kMinInt / divisor));
1163 __ jmp(&done, Label::kNear);
1158 __ bind(&not_kmin_int); 1164 __ bind(&not_kmin_int);
1159 __ sarl(dividend, Immediate(shift)); 1165 __ sarl(dividend, Immediate(shift));
1160 __ bind(&done); 1166 __ bind(&done);
1161 } 1167 }
1162 1168
1163 1169
1164 void LCodeGen::DoFlooringDivByConstI(LFlooringDivByConstI* instr) { 1170 void LCodeGen::DoFlooringDivByConstI(LFlooringDivByConstI* instr) {
1165 Register dividend = ToRegister(instr->dividend()); 1171 Register dividend = ToRegister(instr->dividend());
1166 int32_t divisor = instr->divisor(); 1172 int32_t divisor = instr->divisor();
1167 ASSERT(ToRegister(instr->result()).is(rdx)); 1173 ASSERT(ToRegister(instr->result()).is(rdx));
(...skipping 4513 matching lines...) Expand 10 before | Expand all | Expand 10 after
5681 __ bind(deferred->exit()); 5687 __ bind(deferred->exit());
5682 __ bind(&done); 5688 __ bind(&done);
5683 } 5689 }
5684 5690
5685 5691
5686 #undef __ 5692 #undef __
5687 5693
5688 } } // namespace v8::internal 5694 } } // namespace v8::internal
5689 5695
5690 #endif // V8_TARGET_ARCH_X64 5696 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/ia32/lithium-codegen-ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698