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

Side by Side Diff: src/arm64/lithium-codegen-arm64.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/arm/lithium-codegen-arm.cc ('k') | src/ia32/lithium-codegen-ia32.cc » ('j') | 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 3833 matching lines...) Expand 10 before | Expand all | Expand 10 after
3844 // If the divisor is positive, things are easy: There can be no deopts and we 3844 // If the divisor is positive, things are easy: There can be no deopts and we
3845 // can simply do an arithmetic right shift. 3845 // can simply do an arithmetic right shift.
3846 if (divisor == 1) return; 3846 if (divisor == 1) return;
3847 int32_t shift = WhichPowerOf2Abs(divisor); 3847 int32_t shift = WhichPowerOf2Abs(divisor);
3848 if (divisor > 1) { 3848 if (divisor > 1) {
3849 __ Mov(result, Operand(dividend, ASR, shift)); 3849 __ Mov(result, Operand(dividend, ASR, shift));
3850 return; 3850 return;
3851 } 3851 }
3852 3852
3853 // If the divisor is negative, we have to negate and handle edge cases. 3853 // If the divisor is negative, we have to negate and handle edge cases.
3854 Label not_kmin_int, done;
3855 __ Negs(result, dividend); 3854 __ Negs(result, dividend);
3856 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { 3855 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
3857 DeoptimizeIf(eq, instr->environment()); 3856 DeoptimizeIf(eq, instr->environment());
3858 } 3857 }
3859 if (instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) { 3858
3860 // Note that we could emit branch-free code, but that would need one more 3859 // If the negation could not overflow, simply shifting is OK.
3861 // register. 3860 if (!instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) {
3862 if (divisor == -1) { 3861 __ Mov(result, Operand(dividend, ASR, shift));
3863 DeoptimizeIf(vs, instr->environment()); 3862 return;
3864 } else {
3865 __ B(vc, &not_kmin_int);
3866 __ Mov(result, kMinInt / divisor);
3867 __ B(&done);
3868 }
3869 } 3863 }
3864
3865 // Dividing by -1 is basically negation, unless we overflow.
3866 if (divisor == -1) {
3867 DeoptimizeIf(vs, instr->environment());
3868 return;
3869 }
3870
3871 // Using a conditional data processing instruction would need 1 more register.
3872 Label not_kmin_int, done;
3873 __ B(vc, &not_kmin_int);
3874 __ Mov(result, kMinInt / divisor);
3875 __ B(&done);
3870 __ bind(&not_kmin_int); 3876 __ bind(&not_kmin_int);
3871 __ Mov(result, Operand(dividend, ASR, shift)); 3877 __ Mov(result, Operand(dividend, ASR, shift));
3872 __ bind(&done); 3878 __ bind(&done);
3873 } 3879 }
3874 3880
3875 3881
3876 void LCodeGen::DoFlooringDivByConstI(LFlooringDivByConstI* instr) { 3882 void LCodeGen::DoFlooringDivByConstI(LFlooringDivByConstI* instr) {
3877 Register dividend = ToRegister32(instr->dividend()); 3883 Register dividend = ToRegister32(instr->dividend());
3878 int32_t divisor = instr->divisor(); 3884 int32_t divisor = instr->divisor();
3879 Register result = ToRegister32(instr->result()); 3885 Register result = ToRegister32(instr->result());
(...skipping 2039 matching lines...) Expand 10 before | Expand all | Expand 10 after
5919 __ Ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); 5925 __ Ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset));
5920 // Index is equal to negated out of object property index plus 1. 5926 // Index is equal to negated out of object property index plus 1.
5921 __ Sub(result, result, Operand::UntagSmiAndScale(index, kPointerSizeLog2)); 5927 __ Sub(result, result, Operand::UntagSmiAndScale(index, kPointerSizeLog2));
5922 __ Ldr(result, FieldMemOperand(result, 5928 __ Ldr(result, FieldMemOperand(result,
5923 FixedArray::kHeaderSize - kPointerSize)); 5929 FixedArray::kHeaderSize - kPointerSize));
5924 __ Bind(deferred->exit()); 5930 __ Bind(deferred->exit());
5925 __ Bind(&done); 5931 __ Bind(&done);
5926 } 5932 }
5927 5933
5928 } } // namespace v8::internal 5934 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-codegen-arm.cc ('k') | src/ia32/lithium-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698