summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoger Sayle <roger@nextmovesoftware.com>2022-05-23 08:47:42 +0100
committerRoger Sayle <roger@nextmovesoftware.com>2022-05-23 08:47:42 +0100
commit7707d7fddf7d6858399c8a47b139dc4708c5d7d9 (patch)
treea426ea691f3525546d8b5bd081ddeca1b59ad1d7
parentRISC-V: Fix canonical extension order (K and J) (diff)
downloadgcc-7707d7fddf7d6858399c8a47b139dc4708c5d7d9.tar.gz
gcc-7707d7fddf7d6858399c8a47b139dc4708c5d7d9.tar.bz2
gcc-7707d7fddf7d6858399c8a47b139dc4708c5d7d9.tar.xz
Some additional ix86_rtx_costs clean-ups: NEG, AND, andn and pandn.
Double-word NOT requires two operations, but double-word NEG requires three operations. Using SSE, vector NOT requires a pxor with -1, but AND of NOT is cheap thanks to the existence of pandn. There's also some legacy (aka incorrect) logic explicitly testing for DImode [independently of TARGET_64BIT] in determining the cost of logic operations that's not required. 2022-05-23 Roger Sayle <roger@nextmovesoftware.com> gcc/ChangeLog * config/i386/i386.cc (ix86_rtx_costs) <case AND>: Split from XOR/IOR case. Account for two instructions for double-word operations. In case of vector pandn, account for single instruction. Likewise for integer andn with TARGET_BMI. <case NOT>: Vector NOT requires more than 1 instruction (pxor). <case NEG>: Double-word negation requires 3 instructions.
-rw-r--r--gcc/config/i386/i386.cc133
1 files changed, 94 insertions, 39 deletions
diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index 30a9cd006e8..daa60acdc05 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -20738,70 +20738,125 @@ ix86_rtx_costs (rtx x, machine_mode mode, int outer_code_i, int opno,
20738 } 20738 }
20739 20739
20740 if (SSE_FLOAT_MODE_SSEMATH_OR_HF_P (mode)) 20740 if (SSE_FLOAT_MODE_SSEMATH_OR_HF_P (mode))
20741 { 20741 *total = cost->addss;
20742 *total = cost->addss;
20743 return false;
20744 }
20745 else if (X87_FLOAT_MODE_P (mode)) 20742 else if (X87_FLOAT_MODE_P (mode))
20746 { 20743 *total = cost->fadd;
20747 *total = cost->fadd;
20748 return false;
20749 }
20750 else if (FLOAT_MODE_P (mode)) 20744 else if (FLOAT_MODE_P (mode))
20751 { 20745 *total = ix86_vec_cost (mode, cost->addss);
20752 *total = ix86_vec_cost (mode, cost->addss); 20746 else if (GET_MODE_CLASS (mode) == MODE_VECTOR_INT)
20753 return false; 20747 *total = ix86_vec_cost (mode, cost->sse_op);
20754 } 20748 else if (GET_MODE_SIZE (mode) > UNITS_PER_WORD)
20755 /* FALLTHRU */ 20749 *total = cost->add * 2;
20750 else
20751 *total = cost->add;
20752 return false;
20756 20753
20757 case AND:
20758 case IOR: 20754 case IOR:
20759 case XOR: 20755 case XOR:
20760 if (GET_MODE_CLASS (mode) == MODE_INT 20756 if (GET_MODE_CLASS (mode) == MODE_VECTOR_INT)
20761 && GET_MODE_SIZE (mode) > UNITS_PER_WORD) 20757 *total = ix86_vec_cost (mode, cost->sse_op);
20758 else if (GET_MODE_SIZE (mode) > UNITS_PER_WORD)
20759 *total = cost->add * 2;
20760 else
20761 *total = cost->add;
20762 return false;
20763
20764 case AND:
20765 if (address_no_seg_operand (x, mode))
20762 { 20766 {
20763 *total = (cost->add * 2 20767 *total = cost->lea;
20764 + (rtx_cost (XEXP (x, 0), mode, outer_code, opno, speed)
20765 << (GET_MODE (XEXP (x, 0)) != DImode))
20766 + (rtx_cost (XEXP (x, 1), mode, outer_code, opno, speed)
20767 << (GET_MODE (XEXP (x, 1)) != DImode)));
20768 return true; 20768 return true;
20769 } 20769 }
20770 else if (code == AND 20770 else if (GET_MODE_CLASS (mode) == MODE_VECTOR_INT)
20771 && address_no_seg_operand (x, mode))
20772 { 20771 {
20773 *total = cost->lea; 20772 /* pandn is a single instruction. */
20774 return true; 20773 if (GET_CODE (XEXP (x, 0)) == NOT)
20774 {
20775 *total = ix86_vec_cost (mode, cost->sse_op)
20776 + rtx_cost (XEXP (XEXP (x, 0), 0), mode,
20777 outer_code, opno, speed)
20778 + rtx_cost (XEXP (x, 1), mode,
20779 outer_code, opno, speed);
20780 return true;
20781 }
20782 else if (GET_CODE (XEXP (x, 1)) == NOT)
20783 {
20784 *total = ix86_vec_cost (mode, cost->sse_op)
20785 + rtx_cost (XEXP (x, 0), mode,
20786 outer_code, opno, speed)
20787 + rtx_cost (XEXP (XEXP (x, 1), 0), mode,
20788 outer_code, opno, speed);
20789 return true;
20790 }
20791 *total = ix86_vec_cost (mode, cost->sse_op);
20775 } 20792 }
20776 /* FALLTHRU */ 20793 else if (GET_MODE_SIZE (mode) > UNITS_PER_WORD)
20777
20778 case NEG:
20779 if (SSE_FLOAT_MODE_SSEMATH_OR_HF_P (mode))
20780 { 20794 {
20781 *total = cost->sse_op; 20795 if (TARGET_BMI && GET_CODE (XEXP (x,0)) == NOT)
20782 return false; 20796 {
20797 *total = cost->add * 2
20798 + rtx_cost (XEXP (XEXP (x, 0), 0), mode,
20799 outer_code, opno, speed)
20800 + rtx_cost (XEXP (x, 1), mode,
20801 outer_code, opno, speed);
20802 return true;
20803 }
20804 else if (TARGET_BMI && GET_CODE (XEXP (x, 1)) == NOT)
20805 {
20806 *total = cost->add * 2
20807 + rtx_cost (XEXP (x, 0), mode,
20808 outer_code, opno, speed)
20809 + rtx_cost (XEXP (XEXP (x, 1), 0), mode,
20810 outer_code, opno, speed);
20811 return true;
20812 }
20813 *total = cost->add * 2;
20783 } 20814 }
20784 else if (X87_FLOAT_MODE_P (mode)) 20815 else if (TARGET_BMI && GET_CODE (XEXP (x,0)) == NOT)
20785 { 20816 {
20786 *total = cost->fchs; 20817 *total = cost->add
20787 return false; 20818 + rtx_cost (XEXP (XEXP (x, 0), 0), mode,
20819 outer_code, opno, speed)
20820 + rtx_cost (XEXP (x, 1), mode, outer_code, opno, speed);
20821 return true;
20788 } 20822 }
20789 else if (FLOAT_MODE_P (mode)) 20823 else if (TARGET_BMI && GET_CODE (XEXP (x,1)) == NOT)
20790 { 20824 {
20791 *total = ix86_vec_cost (mode, cost->sse_op); 20825 *total = cost->add
20792 return false; 20826 + rtx_cost (XEXP (x, 0), mode, outer_code, opno, speed)
20827 + rtx_cost (XEXP (XEXP (x, 1), 0), mode,
20828 outer_code, opno, speed);
20829 return true;
20793 } 20830 }
20794 /* FALLTHRU */ 20831 else
20832 *total = cost->add;
20833 return false;
20795 20834
20796 case NOT: 20835 case NOT:
20797 if (GET_MODE_CLASS (mode) == MODE_VECTOR_INT) 20836 if (GET_MODE_CLASS (mode) == MODE_VECTOR_INT)
20798 *total = ix86_vec_cost (mode, cost->sse_op); 20837 // vnot is pxor -1.
20838 *total = ix86_vec_cost (mode, cost->sse_op) + 1;
20799 else if (GET_MODE_SIZE (mode) > UNITS_PER_WORD) 20839 else if (GET_MODE_SIZE (mode) > UNITS_PER_WORD)
20800 *total = cost->add * 2; 20840 *total = cost->add * 2;
20801 else 20841 else
20802 *total = cost->add; 20842 *total = cost->add;
20803 return false; 20843 return false;
20804 20844
20845 case NEG:
20846 if (SSE_FLOAT_MODE_SSEMATH_OR_HF_P (mode))
20847 *total = cost->sse_op;
20848 else if (X87_FLOAT_MODE_P (mode))
20849 *total = cost->fchs;
20850 else if (FLOAT_MODE_P (mode))
20851 *total = ix86_vec_cost (mode, cost->sse_op);
20852 else if (GET_MODE_CLASS (mode) == MODE_VECTOR_INT)
20853 *total = ix86_vec_cost (mode, cost->sse_op);
20854 else if (GET_MODE_SIZE (mode) > UNITS_PER_WORD)
20855 *total = cost->add * 3;
20856 else
20857 *total = cost->add;
20858 return false;
20859
20805 case COMPARE: 20860 case COMPARE:
20806 rtx op0, op1; 20861 rtx op0, op1;
20807 op0 = XEXP (x, 0); 20862 op0 = XEXP (x, 0);