Commit d2e8b6ae by Jakub Jelinek Committed by Jakub Jelinek

re PR target/90568 (stack protector should use cmp or sub, not xor, to allow macro-fusion on x86)

	PR target/90568
	* config/i386/x86-tune-sched.c (ix86_macro_funsion_pair_p): Call
	gen_attr_type just once instead of 4-7 times.  Formatting fixes.
	Handle stack_protect_test_<mode> codegen similarly to corresponding
	sub instruction.

From-SVN: r271596
parent 1d672917
2019-05-24 Jakub Jelinek <jakub@redhat.com>
PR target/90568
* config/i386/x86-tune-sched.c (ix86_macro_funsion_pair_p): Call
gen_attr_type just once instead of 4-7 times. Formatting fixes.
Handle stack_protect_test_<mode> codegen similarly to corresponding
sub instruction.
2019-05-23 Iain Sandoe <iain@sandoe.co.uk> 2019-05-23 Iain Sandoe <iain@sandoe.co.uk>
* config/i386/darwin.h: Reject -mfentry*. * config/i386/darwin.h: Reject -mfentry*.
......
...@@ -525,6 +525,7 @@ ix86_macro_fusion_pair_p (rtx_insn *condgen, rtx_insn *condjmp) ...@@ -525,6 +525,7 @@ ix86_macro_fusion_pair_p (rtx_insn *condgen, rtx_insn *condjmp)
enum rtx_code ccode; enum rtx_code ccode;
rtx compare_set = NULL_RTX, test_if, cond; rtx compare_set = NULL_RTX, test_if, cond;
rtx alu_set = NULL_RTX, addr = NULL_RTX; rtx alu_set = NULL_RTX, addr = NULL_RTX;
enum attr_type condgen_type;
if (!any_condjump_p (condjmp)) if (!any_condjump_p (condjmp))
return false; return false;
...@@ -538,15 +539,26 @@ ix86_macro_fusion_pair_p (rtx_insn *condgen, rtx_insn *condjmp) ...@@ -538,15 +539,26 @@ ix86_macro_fusion_pair_p (rtx_insn *condgen, rtx_insn *condjmp)
|| !modified_in_p (cc_reg_1, condgen)) || !modified_in_p (cc_reg_1, condgen))
return false; return false;
if (get_attr_type (condgen) != TYPE_TEST condgen_type = get_attr_type (condgen);
&& get_attr_type (condgen) != TYPE_ICMP if (condgen_type == TYPE_MULTI
&& get_attr_type (condgen) != TYPE_INCDEC && (INSN_CODE (condgen) == CODE_FOR_stack_protect_test_di
&& get_attr_type (condgen) != TYPE_ALU) || INSN_CODE (condgen) == CODE_FOR_stack_protect_test_si)
&& TARGET_FUSE_ALU_AND_BRANCH)
{
/* stack_protect_test_<mode> ends with a sub, which subtracts
a non-rip special memory operand from a GPR. */
src = NULL_RTX;
alu_set = XVECEXP (PATTERN (condgen), 0, 1);
goto handle_stack_protect_test;
}
else if (condgen_type != TYPE_TEST
&& condgen_type != TYPE_ICMP
&& condgen_type != TYPE_INCDEC
&& condgen_type != TYPE_ALU)
return false; return false;
compare_set = single_set (condgen); compare_set = single_set (condgen);
if (compare_set == NULL_RTX if (compare_set == NULL_RTX && !TARGET_FUSE_ALU_AND_BRANCH)
&& !TARGET_FUSE_ALU_AND_BRANCH)
return false; return false;
if (compare_set == NULL_RTX) if (compare_set == NULL_RTX)
...@@ -571,10 +583,8 @@ ix86_macro_fusion_pair_p (rtx_insn *condgen, rtx_insn *condjmp) ...@@ -571,10 +583,8 @@ ix86_macro_fusion_pair_p (rtx_insn *condgen, rtx_insn *condjmp)
/* Macro-fusion for cmp/test MEM-IMM + conditional jmp is not /* Macro-fusion for cmp/test MEM-IMM + conditional jmp is not
supported. */ supported. */
if ((MEM_P (XEXP (src, 0)) if ((MEM_P (XEXP (src, 0)) && CONST_INT_P (XEXP (src, 1)))
&& CONST_INT_P (XEXP (src, 1))) || (MEM_P (XEXP (src, 1)) && CONST_INT_P (XEXP (src, 0))))
|| (MEM_P (XEXP (src, 1))
&& CONST_INT_P (XEXP (src, 0))))
return false; return false;
/* No fusion for RIP-relative address. */ /* No fusion for RIP-relative address. */
...@@ -583,29 +593,27 @@ ix86_macro_fusion_pair_p (rtx_insn *condgen, rtx_insn *condjmp) ...@@ -583,29 +593,27 @@ ix86_macro_fusion_pair_p (rtx_insn *condgen, rtx_insn *condjmp)
else if (MEM_P (XEXP (src, 1))) else if (MEM_P (XEXP (src, 1)))
addr = XEXP (XEXP (src, 1), 0); addr = XEXP (XEXP (src, 1), 0);
if (addr) { if (addr)
ix86_address parts; {
int ok = ix86_decompose_address (addr, &parts); ix86_address parts;
gcc_assert (ok); int ok = ix86_decompose_address (addr, &parts);
gcc_assert (ok);
if (ix86_rip_relative_addr_p (&parts)) if (ix86_rip_relative_addr_p (&parts))
return false; return false;
} }
handle_stack_protect_test:
test_if = SET_SRC (pc_set (condjmp)); test_if = SET_SRC (pc_set (condjmp));
cond = XEXP (test_if, 0); cond = XEXP (test_if, 0);
ccode = GET_CODE (cond); ccode = GET_CODE (cond);
/* Check whether conditional jump use Sign or Overflow Flags. */ /* Check whether conditional jump use Sign or Overflow Flags. */
if (!TARGET_FUSE_CMP_AND_BRANCH_SOFLAGS if (!TARGET_FUSE_CMP_AND_BRANCH_SOFLAGS
&& (ccode == GE && (ccode == GE || ccode == GT || ccode == LE || ccode == LT))
|| ccode == GT
|| ccode == LE
|| ccode == LT))
return false; return false;
/* Return true for TYPE_TEST and TYPE_ICMP. */ /* Return true for TYPE_TEST and TYPE_ICMP. */
if (get_attr_type (condgen) == TYPE_TEST if (condgen_type == TYPE_TEST || condgen_type == TYPE_ICMP)
|| get_attr_type (condgen) == TYPE_ICMP)
return true; return true;
/* The following is the case that macro-fusion for alu + jmp. */ /* The following is the case that macro-fusion for alu + jmp. */
...@@ -619,11 +627,8 @@ ix86_macro_fusion_pair_p (rtx_insn *condgen, rtx_insn *condjmp) ...@@ -619,11 +627,8 @@ ix86_macro_fusion_pair_p (rtx_insn *condgen, rtx_insn *condjmp)
/* Macro-fusion for inc/dec + unsigned conditional jump is not /* Macro-fusion for inc/dec + unsigned conditional jump is not
supported. */ supported. */
if (get_attr_type (condgen) == TYPE_INCDEC if (condgen_type == TYPE_INCDEC
&& (ccode == GEU && (ccode == GEU || ccode == GTU || ccode == LEU || ccode == LTU))
|| ccode == GTU
|| ccode == LEU
|| ccode == LTU))
return false; return false;
return true; return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment