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

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

Issue 6835021: X64: Use roundsd for DoMathFloor. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed review comments Created 9 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/x64/disasm-x64.cc ('k') | test/mjsunit/math-floor.js » ('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 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 2680 matching lines...) Expand 10 before | Expand all | Expand 10 after
2691 EmitIntegerMathAbs(instr); 2691 EmitIntegerMathAbs(instr);
2692 __ bind(deferred->exit()); 2692 __ bind(deferred->exit());
2693 } 2693 }
2694 } 2694 }
2695 2695
2696 2696
2697 void LCodeGen::DoMathFloor(LUnaryMathOperation* instr) { 2697 void LCodeGen::DoMathFloor(LUnaryMathOperation* instr) {
2698 XMMRegister xmm_scratch = xmm0; 2698 XMMRegister xmm_scratch = xmm0;
2699 Register output_reg = ToRegister(instr->result()); 2699 Register output_reg = ToRegister(instr->result());
2700 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0)); 2700 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0));
2701 __ xorpd(xmm_scratch, xmm_scratch); // Zero the register.
2702 __ ucomisd(input_reg, xmm_scratch);
2703 2701
2704 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { 2702 if (CpuFeatures::IsSupported(SSE4_1)) {
2705 DeoptimizeIf(below_equal, instr->environment()); 2703 CpuFeatures::Scope scope(SSE4_1);
2704 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
2705 // Deoptimize if minus zero.
2706 __ movq(output_reg, input_reg);
2707 __ subq(output_reg, Immediate(1));
2708 DeoptimizeIf(overflow, instr->environment());
2709 }
2710 __ roundsd(xmm_scratch, input_reg, Assembler::kRoundDown);
2711 __ cvttsd2si(output_reg, xmm_scratch);
2712 __ cmpl(output_reg, Immediate(0x80000000));
2713 DeoptimizeIf(equal, instr->environment());
2706 } else { 2714 } else {
2707 DeoptimizeIf(below, instr->environment()); 2715 __ xorpd(xmm_scratch, xmm_scratch); // Zero the register.
2716 __ ucomisd(input_reg, xmm_scratch);
2717
2718 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
2719 DeoptimizeIf(below_equal, instr->environment());
2720 } else {
2721 DeoptimizeIf(below, instr->environment());
2722 }
2723
2724 // Use truncating instruction (OK because input is positive).
2725 __ cvttsd2si(output_reg, input_reg);
2726
2727 // Overflow is signalled with minint.
2728 __ cmpl(output_reg, Immediate(0x80000000));
2729 DeoptimizeIf(equal, instr->environment());
2708 } 2730 }
2709
2710 // Use truncating instruction (OK because input is positive).
2711 __ cvttsd2si(output_reg, input_reg);
2712
2713 // Overflow is signalled with minint.
2714 __ cmpl(output_reg, Immediate(0x80000000));
2715 DeoptimizeIf(equal, instr->environment());
2716 } 2731 }
2717 2732
2718 2733
2719 void LCodeGen::DoMathRound(LUnaryMathOperation* instr) { 2734 void LCodeGen::DoMathRound(LUnaryMathOperation* instr) {
2720 const XMMRegister xmm_scratch = xmm0; 2735 const XMMRegister xmm_scratch = xmm0;
2721 Register output_reg = ToRegister(instr->result()); 2736 Register output_reg = ToRegister(instr->result());
2722 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0)); 2737 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0));
2723 2738
2724 Label done; 2739 Label done;
2725 // xmm_scratch = 0.5 2740 // xmm_scratch = 0.5
(...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after
4006 RegisterEnvironmentForDeoptimization(environment); 4021 RegisterEnvironmentForDeoptimization(environment);
4007 ASSERT(osr_pc_offset_ == -1); 4022 ASSERT(osr_pc_offset_ == -1);
4008 osr_pc_offset_ = masm()->pc_offset(); 4023 osr_pc_offset_ = masm()->pc_offset();
4009 } 4024 }
4010 4025
4011 #undef __ 4026 #undef __
4012 4027
4013 } } // namespace v8::internal 4028 } } // namespace v8::internal
4014 4029
4015 #endif // V8_TARGET_ARCH_X64 4030 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/disasm-x64.cc ('k') | test/mjsunit/math-floor.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698