From 869d095e242efc092bb6c009a281ca20ad30abc3 Mon Sep 17 00:00:00 2001 From: Uros Bizjak Date: Tue, 14 Sep 2004 07:21:51 +0200 Subject: [PATCH] i386.c (output_fp_compare): Add generation of ftst instruction. * config/i386/i386.c (output_fp_compare): Add generation of ftst instruction. * config/i386/i386.md (*cmpfp_0_sf, cmpfp_0_df, cmpfp_0_xf): Use output_fp_compare () function. (cmpfp_i, *cmpfp_i_sse, *cmpfp_i_sse_only): Fix insn constraint. (fix_truncdi_memory): Remove operands[5] copy. From-SVN: r87482 --- gcc/ChangeLog | 9 +++++++++ gcc/config/i386/i386.c | 22 +++++++++++++++++++--- gcc/config/i386/i386.md | 38 +++++++------------------------------- 3 files changed, 35 insertions(+), 34 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 28457ba7824..3cd560d7943 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2004-09-14 Uros Bizjak + + * config/i386/i386.c (output_fp_compare): Add generation + of ftst instruction. + * config/i386/i386.md (*cmpfp_0_sf, cmpfp_0_df, cmpfp_0_xf): + Use output_fp_compare () function. + (cmpfp_i, *cmpfp_i_sse, *cmpfp_i_sse_only): Fix insn constraint. + (fix_truncdi_memory): Remove operands[5] copy. + 2004-09-14 Kazu Hirata * config/m32r/m32r.md, config/m68k/m68kelf.h, diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 75935ab75e8..8f5364fff66 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -7228,15 +7228,20 @@ const char * output_fp_compare (rtx insn, rtx *operands, int eflags_p, int unordered_p) { int stack_top_dies; - rtx cmp_op0 = operands[0]; - rtx cmp_op1 = operands[1]; + rtx cmp_op0, cmp_op1; int is_sse = SSE_REG_P (operands[0]) | SSE_REG_P (operands[1]); if (eflags_p == 2) { - cmp_op0 = cmp_op1; + cmp_op0 = operands[1]; cmp_op1 = operands[2]; } + else + { + cmp_op0 = operands[0]; + cmp_op1 = operands[1]; + } + if (is_sse) { if (GET_MODE (operands[0]) == SFmode) @@ -7256,6 +7261,17 @@ output_fp_compare (rtx insn, rtx *operands, int eflags_p, int unordered_p) stack_top_dies = find_regno_note (insn, REG_DEAD, FIRST_STACK_REG) != 0; + if (cmp_op1 == CONST0_RTX (GET_MODE (cmp_op1))) + { + if (stack_top_dies) + { + output_asm_insn ("ftst\n\tfnstsw\t%0", operands); + return TARGET_USE_FFREEP ? "ffreep\t%y1" : "fstp\t%y1"; + } + else + return "ftst\n\tfnstsw\t%0"; + } + if (STACK_REG_P (cmp_op1) && stack_top_dies && find_regno_note (insn, REG_DEAD, REGNO (cmp_op1)) diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index f2f3fbedbdf..168f2f37a1b 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -805,15 +805,7 @@ (match_operand:SF 2 "const0_operand" "X"))] UNSPEC_FNSTSW))] "TARGET_80387" -{ - if (find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) - { - output_asm_insn ("ftst\;fnstsw\t%0", operands); - return TARGET_USE_FFREEP ? "ffreep\t%y1" : "fstp\t%y1"; - } - else - return "ftst\;fnstsw\t%0"; -} + "* return output_fp_compare (insn, operands, 2, 0);" [(set_attr "type" "multi") (set_attr "mode" "SF")]) @@ -825,15 +817,7 @@ (match_operand:DF 2 "const0_operand" "X"))] UNSPEC_FNSTSW))] "TARGET_80387" -{ - if (find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) - { - output_asm_insn ("ftst\;fnstsw\t%0", operands); - return TARGET_USE_FFREEP ? "ffreep\t%y1" : "fstp\t%y1"; - } - else - return "ftst\;fnstsw\t%0"; -} + "* return output_fp_compare (insn, operands, 2, 0);" [(set_attr "type" "multi") (set_attr "mode" "DF")]) @@ -845,15 +829,7 @@ (match_operand:XF 2 "const0_operand" "X"))] UNSPEC_FNSTSW))] "TARGET_80387" -{ - if (find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) - { - output_asm_insn ("ftst\;fnstsw\t%0", operands); - return TARGET_USE_FFREEP ? "ffreep\t%y1" : "fstp\t%y1"; - } - else - return "ftst\;fnstsw\t%0"; -} + "* return output_fp_compare (insn, operands, 2, 0);" [(set_attr "type" "multi") (set_attr "mode" "XF")]) @@ -1032,7 +1008,7 @@ "TARGET_80387 && TARGET_CMOVE && !SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && FLOAT_MODE_P (GET_MODE (operands[0])) - && GET_MODE (operands[0]) == GET_MODE (operands[0])" + && GET_MODE (operands[0]) == GET_MODE (operands[1])" "* return output_fp_compare (insn, operands, 1, 0);" [(set_attr "type" "fcmp") (set (attr "mode") @@ -1050,7 +1026,7 @@ (match_operand 1 "nonimmediate_operand" "f#x,xm#f")))] "TARGET_80387 && SSE_FLOAT_MODE_P (GET_MODE (operands[0])) - && GET_MODE (operands[0]) == GET_MODE (operands[0])" + && GET_MODE (operands[0]) == GET_MODE (operands[1])" "* return output_fp_compare (insn, operands, 1, 0);" [(set_attr "type" "fcmp,ssecomi") (set (attr "mode") @@ -1064,7 +1040,7 @@ (compare:CCFP (match_operand 0 "register_operand" "x") (match_operand 1 "nonimmediate_operand" "xm")))] "SSE_FLOAT_MODE_P (GET_MODE (operands[0])) - && GET_MODE (operands[0]) == GET_MODE (operands[0])" + && GET_MODE (operands[0]) == GET_MODE (operands[1])" "* return output_fp_compare (insn, operands, 1, 0);" [(set_attr "type" "ssecomi") (set (attr "mode") @@ -4161,7 +4137,7 @@ (clobber (match_scratch:DF 4 "=&1f"))] "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1])) && (!SSE_FLOAT_MODE_P (GET_MODE (operands[1])) || !TARGET_64BIT)" - "* operands[5] = operands[4]; return output_fix_trunc (insn, operands);" + "* return output_fix_trunc (insn, operands);" [(set_attr "type" "fistp") (set_attr "i387_cw" "trunc") (set_attr "mode" "DI")]) -- 2.30.2