comparison src/share/vm/c1/c1_LIR.cpp @ 6084:6759698e3140

7133857: exp() and pow() should use the x87 ISA on x86 Summary: use x87 instructions to implement exp() and pow() in interpreter/c1/c2. Reviewed-by: kvn, never, twisti
author roland
date Tue, 15 May 2012 10:10:23 +0200
parents 701a83c86f28
children da91efe96a93
comparison
equal deleted inserted replaced
6057:8f972594effc 6084:6759698e3140
622 case lir_shr: 622 case lir_shr:
623 case lir_ushr: 623 case lir_ushr:
624 { 624 {
625 assert(op->as_Op2() != NULL, "must be"); 625 assert(op->as_Op2() != NULL, "must be");
626 LIR_Op2* op2 = (LIR_Op2*)op; 626 LIR_Op2* op2 = (LIR_Op2*)op;
627 assert(op2->_tmp2->is_illegal() && op2->_tmp3->is_illegal() &&
628 op2->_tmp4->is_illegal() && op2->_tmp5->is_illegal(), "not used");
627 629
628 if (op2->_info) do_info(op2->_info); 630 if (op2->_info) do_info(op2->_info);
629 if (op2->_opr1->is_valid()) do_input(op2->_opr1); 631 if (op2->_opr1->is_valid()) do_input(op2->_opr1);
630 if (op2->_opr2->is_valid()) do_input(op2->_opr2); 632 if (op2->_opr2->is_valid()) do_input(op2->_opr2);
631 if (op2->_tmp->is_valid()) do_temp(op2->_tmp); 633 if (op2->_tmp1->is_valid()) do_temp(op2->_tmp1);
632 if (op2->_result->is_valid()) do_output(op2->_result); 634 if (op2->_result->is_valid()) do_output(op2->_result);
633 635
634 break; 636 break;
635 } 637 }
636 638
639 case lir_cmove: 641 case lir_cmove:
640 { 642 {
641 assert(op->as_Op2() != NULL, "must be"); 643 assert(op->as_Op2() != NULL, "must be");
642 LIR_Op2* op2 = (LIR_Op2*)op; 644 LIR_Op2* op2 = (LIR_Op2*)op;
643 645
644 assert(op2->_info == NULL && op2->_tmp->is_illegal(), "not used"); 646 assert(op2->_info == NULL && op2->_tmp1->is_illegal() && op2->_tmp2->is_illegal() &&
647 op2->_tmp3->is_illegal() && op2->_tmp4->is_illegal() && op2->_tmp5->is_illegal(), "not used");
645 assert(op2->_opr1->is_valid() && op2->_opr2->is_valid() && op2->_result->is_valid(), "used"); 648 assert(op2->_opr1->is_valid() && op2->_opr2->is_valid() && op2->_result->is_valid(), "used");
646 649
647 do_input(op2->_opr1); 650 do_input(op2->_opr1);
648 do_input(op2->_opr2); 651 do_input(op2->_opr2);
649 do_temp(op2->_opr2); 652 do_temp(op2->_opr2);
663 666
664 assert(op2->_info == NULL, "not used"); 667 assert(op2->_info == NULL, "not used");
665 assert(op2->_opr1->is_valid(), "used"); 668 assert(op2->_opr1->is_valid(), "used");
666 assert(op2->_opr2->is_valid(), "used"); 669 assert(op2->_opr2->is_valid(), "used");
667 assert(op2->_result->is_valid(), "used"); 670 assert(op2->_result->is_valid(), "used");
671 assert(op2->_tmp2->is_illegal() && op2->_tmp3->is_illegal() &&
672 op2->_tmp4->is_illegal() && op2->_tmp5->is_illegal(), "not used");
668 673
669 do_input(op2->_opr1); do_temp(op2->_opr1); 674 do_input(op2->_opr1); do_temp(op2->_opr1);
670 do_input(op2->_opr2); do_temp(op2->_opr2); 675 do_input(op2->_opr2); do_temp(op2->_opr2);
671 if (op2->_tmp->is_valid()) do_temp(op2->_tmp); 676 if (op2->_tmp1->is_valid()) do_temp(op2->_tmp1);
672 do_output(op2->_result); 677 do_output(op2->_result);
673 678
674 break; 679 break;
675 } 680 }
676 681
680 685
681 if (op2->_info) do_info(op2->_info); 686 if (op2->_info) do_info(op2->_info);
682 if (op2->_opr1->is_valid()) do_temp(op2->_opr1); 687 if (op2->_opr1->is_valid()) do_temp(op2->_opr1);
683 if (op2->_opr2->is_valid()) do_input(op2->_opr2); // exception object is input parameter 688 if (op2->_opr2->is_valid()) do_input(op2->_opr2); // exception object is input parameter
684 assert(op2->_result->is_illegal(), "no result"); 689 assert(op2->_result->is_illegal(), "no result");
690 assert(op2->_tmp2->is_illegal() && op2->_tmp3->is_illegal() &&
691 op2->_tmp4->is_illegal() && op2->_tmp5->is_illegal(), "not used");
685 692
686 break; 693 break;
687 } 694 }
688 695
689 case lir_unwind: { 696 case lir_unwind: {
700 707
701 case lir_tan: 708 case lir_tan:
702 case lir_sin: 709 case lir_sin:
703 case lir_cos: 710 case lir_cos:
704 case lir_log: 711 case lir_log:
705 case lir_log10: { 712 case lir_log10:
713 case lir_exp: {
706 assert(op->as_Op2() != NULL, "must be"); 714 assert(op->as_Op2() != NULL, "must be");
707 LIR_Op2* op2 = (LIR_Op2*)op; 715 LIR_Op2* op2 = (LIR_Op2*)op;
708 716
709 // On x86 tan/sin/cos need two temporary fpu stack slots and 717 // On x86 tan/sin/cos need two temporary fpu stack slots and
710 // log/log10 need one so handle opr2 and tmp as temp inputs. 718 // log/log10 need one so handle opr2 and tmp as temp inputs.
711 // Register input operand as temp to guarantee that it doesn't 719 // Register input operand as temp to guarantee that it doesn't
712 // overlap with the input. 720 // overlap with the input.
713 assert(op2->_info == NULL, "not used"); 721 assert(op2->_info == NULL, "not used");
722 assert(op2->_tmp5->is_illegal(), "not used");
723 assert(op2->_tmp2->is_valid() == (op->code() == lir_exp), "not used");
724 assert(op2->_tmp3->is_valid() == (op->code() == lir_exp), "not used");
725 assert(op2->_tmp4->is_valid() == (op->code() == lir_exp), "not used");
714 assert(op2->_opr1->is_valid(), "used"); 726 assert(op2->_opr1->is_valid(), "used");
715 do_input(op2->_opr1); do_temp(op2->_opr1); 727 do_input(op2->_opr1); do_temp(op2->_opr1);
716 728
717 if (op2->_opr2->is_valid()) do_temp(op2->_opr2); 729 if (op2->_opr2->is_valid()) do_temp(op2->_opr2);
718 if (op2->_tmp->is_valid()) do_temp(op2->_tmp); 730 if (op2->_tmp1->is_valid()) do_temp(op2->_tmp1);
731 if (op2->_tmp2->is_valid()) do_temp(op2->_tmp2);
732 if (op2->_tmp3->is_valid()) do_temp(op2->_tmp3);
733 if (op2->_tmp4->is_valid()) do_temp(op2->_tmp4);
719 if (op2->_result->is_valid()) do_output(op2->_result); 734 if (op2->_result->is_valid()) do_output(op2->_result);
720 735
721 break; 736 break;
722 } 737 }
723 738
739 case lir_pow: {
740 assert(op->as_Op2() != NULL, "must be");
741 LIR_Op2* op2 = (LIR_Op2*)op;
742
743 // On x86 pow needs two temporary fpu stack slots: tmp1 and
744 // tmp2. Register input operands as temps to guarantee that it
745 // doesn't overlap with the temporary slots.
746 assert(op2->_info == NULL, "not used");
747 assert(op2->_opr1->is_valid() && op2->_opr2->is_valid(), "used");
748 assert(op2->_tmp1->is_valid() && op2->_tmp2->is_valid() && op2->_tmp3->is_valid()
749 && op2->_tmp4->is_valid() && op2->_tmp5->is_valid(), "used");
750 assert(op2->_result->is_valid(), "used");
751
752 do_input(op2->_opr1); do_temp(op2->_opr1);
753 do_input(op2->_opr2); do_temp(op2->_opr2);
754 do_temp(op2->_tmp1);
755 do_temp(op2->_tmp2);
756 do_temp(op2->_tmp3);
757 do_temp(op2->_tmp4);
758 do_temp(op2->_tmp5);
759 do_output(op2->_result);
760
761 break;
762 }
724 763
725 // LIR_Op3 764 // LIR_Op3
726 case lir_idiv: 765 case lir_idiv:
727 case lir_irem: { 766 case lir_irem: {
728 assert(op->as_Op3() != NULL, "must be"); 767 assert(op->as_Op3() != NULL, "must be");
1668 case lir_sin: s = "sin"; break; 1707 case lir_sin: s = "sin"; break;
1669 case lir_cos: s = "cos"; break; 1708 case lir_cos: s = "cos"; break;
1670 case lir_tan: s = "tan"; break; 1709 case lir_tan: s = "tan"; break;
1671 case lir_log: s = "log"; break; 1710 case lir_log: s = "log"; break;
1672 case lir_log10: s = "log10"; break; 1711 case lir_log10: s = "log10"; break;
1712 case lir_exp: s = "exp"; break;
1713 case lir_pow: s = "pow"; break;
1673 case lir_logic_and: s = "logic_and"; break; 1714 case lir_logic_and: s = "logic_and"; break;
1674 case lir_logic_or: s = "logic_or"; break; 1715 case lir_logic_or: s = "logic_or"; break;
1675 case lir_logic_xor: s = "logic_xor"; break; 1716 case lir_logic_xor: s = "logic_xor"; break;
1676 case lir_shl: s = "shift_left"; break; 1717 case lir_shl: s = "shift_left"; break;
1677 case lir_shr: s = "shift_right"; break; 1718 case lir_shr: s = "shift_right"; break;
1890 if (code() == lir_cmove) { 1931 if (code() == lir_cmove) {
1891 print_condition(out, condition()); out->print(" "); 1932 print_condition(out, condition()); out->print(" ");
1892 } 1933 }
1893 in_opr1()->print(out); out->print(" "); 1934 in_opr1()->print(out); out->print(" ");
1894 in_opr2()->print(out); out->print(" "); 1935 in_opr2()->print(out); out->print(" ");
1895 if (tmp_opr()->is_valid()) { tmp_opr()->print(out); out->print(" "); } 1936 if (tmp1_opr()->is_valid()) { tmp1_opr()->print(out); out->print(" "); }
1937 if (tmp2_opr()->is_valid()) { tmp2_opr()->print(out); out->print(" "); }
1938 if (tmp3_opr()->is_valid()) { tmp3_opr()->print(out); out->print(" "); }
1939 if (tmp4_opr()->is_valid()) { tmp4_opr()->print(out); out->print(" "); }
1940 if (tmp5_opr()->is_valid()) { tmp5_opr()->print(out); out->print(" "); }
1896 result_opr()->print(out); 1941 result_opr()->print(out);
1897 } 1942 }
1898 1943
1899 void LIR_OpAllocArray::print_instr(outputStream* out) const { 1944 void LIR_OpAllocArray::print_instr(outputStream* out) const {
1900 klass()->print(out); out->print(" "); 1945 klass()->print(out); out->print(" ");