From 42851ff81dbe1ccaa16dbcc070513c181ff61eb7 Mon Sep 17 00:00:00 2001 From: Uros Bizjak Date: Wed, 11 Oct 2017 20:00:55 +0200 Subject: [PATCH] i386.md (*cmp__i387): Do not use float_operator operator predicate. * config/i386/i386.md (*cmp__i387): Do not use float_operator operator predicate. (*cmp__cc_i387): Ditto. * config/i386/predicates.md (float_operator): Remove predicate. * config/i386/i386.md (*jcc_0_i387): Remove insn pattern. (*jccxf_i387): Ditto. (*jcc_i387): Ditto. (*jccu_i387): Ditto. (*jcc__i387): Ditto. (*jcc_*_i387 splitters): Remove. * config/i386/i386-protos.h (ix86_split_fp_branch): Remove prototype. * config/i386/i386.c (ix86_split_fp_branch): Remove. * config/i386/predicates.md (ix86_swapped_fp_comparison_operator): Remove predicate. testsuite/ChangeLog: * gcc.target/i386/387-ficom-1.c: New test. From-SVN: r253653 --- gcc/ChangeLog | 22 ++- gcc/config/i386/i386-protos.h | 3 - gcc/config/i386/i386.c | 25 ---- gcc/config/i386/i386.md | 146 +------------------- gcc/config/i386/predicates.md | 17 --- gcc/testsuite/ChangeLog | 4 + gcc/testsuite/gcc.target/i386/387-ficom-1.c | 41 ++++++ 7 files changed, 71 insertions(+), 187 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/387-ficom-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c596313bb11..6f148dc051c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,23 @@ +2017-10-11 Uros Bizjak + + * config/i386/i386.md (*cmp__i387): + Do not use float_operator operator predicate. + (*cmp__cc_i387): Ditto. + * config/i386/predicates.md (float_operator): Remove predicate. + +2017-10-11 Uros Bizjak + + * config/i386/i386.md (*jcc_0_i387): Remove insn pattern. + (*jccxf_i387): Ditto. + (*jcc_i387): Ditto. + (*jccu_i387): Ditto. + (*jcc__i387): Ditto. + (*jcc_*_i387 splitters): Remove. + * config/i386/i386-protos.h (ix86_split_fp_branch): Remove prototype. + * config/i386/i386.c (ix86_split_fp_branch): Remove. + * config/i386/predicates.md (ix86_swapped_fp_comparison_operator): + Remove predicate. + 2017-10-11 Jan Hubicka * profile-count.h (slow_safe_scale_64bit): New function. @@ -43,7 +63,7 @@ (ix86_atom_sched_reorder): Declare. * i386/i386.c Move all CPU cost tables to x86-tune-costs.h. (COSTS_N_BYTES): Move to x86-tune-costs.h. - (DUMMY_STRINGOP_ALGS):x86-tune-costs.h. + (DUMMY_STRINGOP_ALGS):Move to x86-tune-costs.h. (rip_relative_addr_p): Rename to ... (ix86_rip_relative_addr_p): ... this one; export. (memory_address_length): Update. diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h index ab3d8f95c5d..6a7cdd3ed73 100644 --- a/gcc/config/i386/i386-protos.h +++ b/gcc/config/i386/i386-protos.h @@ -166,9 +166,6 @@ extern void ix86_asm_output_function_label (FILE *, const char *, tree); extern void ix86_call_abi_override (const_tree); extern int ix86_reg_parm_stack_space (const_tree); -extern void ix86_split_fp_branch (enum rtx_code code, rtx, rtx, - rtx, rtx, rtx); - extern bool ix86_libc_has_function (enum function_class fn_class); extern void x86_order_regs_for_local_alloc (void); diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 63058a8d19c..ca060b529d2 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -22259,31 +22259,6 @@ ix86_expand_branch (enum rtx_code code, rtx op0, rtx op1, rtx label) } } -/* Split branch based on floating point condition. */ -void -ix86_split_fp_branch (enum rtx_code code, rtx op1, rtx op2, - rtx target1, rtx target2, rtx tmp) -{ - rtx condition; - rtx_insn *i; - - if (target2 != pc_rtx) - { - std::swap (target1, target2); - code = reverse_condition_maybe_unordered (code); - } - - condition = ix86_expand_fp_compare (code, op1, op2, - tmp); - - i = emit_jump_insn (gen_rtx_SET - (pc_rtx, - gen_rtx_IF_THEN_ELSE (VOIDmode, - condition, target1, target2))); - if (split_branch_probability.initialized_p ()) - add_reg_br_prob_note (i, split_branch_probability); -} - void ix86_expand_setcc (rtx dest, enum rtx_code code, rtx op0, rtx op1) { diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 1a794c0ae06..9e1f85f2993 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -1612,8 +1612,8 @@ (unspec:HI [(compare:CCFP (match_operand:X87MODEF 1 "register_operand" "f") - (match_operator:X87MODEF 3 "float_operator" - [(match_operand:SWI24 2 "memory_operand" "m")]))] + (float:X87MODEF + (match_operand:SWI24 2 "memory_operand" "m")))] UNSPEC_FNSTSW))] "TARGET_80387 && (TARGET_USE_MODE_FIOP @@ -1628,8 +1628,8 @@ [(set (reg:CCFP FLAGS_REG) (compare:CCFP (match_operand:X87MODEF 1 "register_operand" "f") - (match_operator:X87MODEF 3 "float_operator" - [(match_operand:SWI24 2 "memory_operand" "m")]))) + (float:X87MODEF + (match_operand:SWI24 2 "memory_operand" "m")))) (clobber (match_operand:HI 0 "register_operand" "=a"))] "TARGET_80387 && TARGET_SAHF && !TARGET_CMOVE && (TARGET_USE_MODE_FIOP @@ -1640,7 +1640,7 @@ (unspec:HI [(compare:CCFP (match_dup 1) - (match_op_dup 3 [(match_dup 2)]))] + (float:X87MODEF (match_dup 2)))] UNSPEC_FNSTSW)) (set (reg:CC FLAGS_REG) (unspec:CC [(match_dup 0)] UNSPEC_SAHF))] @@ -12032,142 +12032,6 @@ if (! ix86_comparison_operator (operands[0], VOIDmode)) FAIL; }) - -;; Define combination compare-and-branch fp compare instructions to help -;; combine. - -(define_insn "*jcc_0_i387" - [(set (pc) - (if_then_else (match_operator:CCFP 0 "ix86_fp_comparison_operator" - [(match_operand:X87MODEF 1 "register_operand" "f") - (match_operand:X87MODEF 2 "const0_operand")]) - (label_ref (match_operand 3)) - (pc))) - (clobber (reg:CCFP FPSR_REG)) - (clobber (reg:CCFP FLAGS_REG)) - (clobber (match_scratch:HI 4 "=a"))] - "TARGET_80387 && !TARGET_CMOVE" - "#") - -(define_insn "*jccxf_i387" - [(set (pc) - (if_then_else (match_operator:CCFP 0 "ix86_fp_comparison_operator" - [(match_operand:XF 1 "register_operand" "f") - (match_operand:XF 2 "register_operand" "f")]) - (label_ref (match_operand 3)) - (pc))) - (clobber (reg:CCFP FPSR_REG)) - (clobber (reg:CCFP FLAGS_REG)) - (clobber (match_scratch:HI 4 "=a"))] - "TARGET_80387 && !TARGET_CMOVE" - "#") - -(define_insn "*jcc_i387" - [(set (pc) - (if_then_else (match_operator:CCFP 0 "ix86_fp_comparison_operator" - [(match_operand:MODEF 1 "register_operand" "f") - (match_operand:MODEF 2 "nonimmediate_operand" "fm")]) - (label_ref (match_operand 3)) - (pc))) - (clobber (reg:CCFP FPSR_REG)) - (clobber (reg:CCFP FLAGS_REG)) - (clobber (match_scratch:HI 4 "=a"))] - "TARGET_80387 && !TARGET_CMOVE" - "#") - -(define_insn "*jccu_i387" - [(set (pc) - (if_then_else (match_operator:CCFPU 0 "ix86_fp_comparison_operator" - [(match_operand:X87MODEF 1 "register_operand" "f") - (match_operand:X87MODEF 2 "register_operand" "f")]) - (label_ref (match_operand 3)) - (pc))) - (clobber (reg:CCFP FPSR_REG)) - (clobber (reg:CCFP FLAGS_REG)) - (clobber (match_scratch:HI 4 "=a"))] - "TARGET_80387 && !TARGET_CMOVE" - "#") - -(define_split - [(set (pc) - (if_then_else (match_operator 0 "ix86_fp_comparison_operator" - [(match_operand:X87MODEF 1 "register_operand") - (match_operand:X87MODEF 2 "nonimmediate_operand")]) - (match_operand 3) - (match_operand 4))) - (clobber (reg:CCFP FPSR_REG)) - (clobber (reg:CCFP FLAGS_REG))] - "TARGET_80387 && !TARGET_CMOVE - && reload_completed" - [(const_int 0)] -{ - ix86_split_fp_branch (GET_CODE (operands[0]), operands[1], operands[2], - operands[3], operands[4], NULL_RTX); - DONE; -}) - -(define_split - [(set (pc) - (if_then_else (match_operator 0 "ix86_fp_comparison_operator" - [(match_operand:X87MODEF 1 "register_operand") - (match_operand:X87MODEF 2 "general_operand")]) - (match_operand 3) - (match_operand 4))) - (clobber (reg:CCFP FPSR_REG)) - (clobber (reg:CCFP FLAGS_REG)) - (clobber (match_scratch:HI 5))] - "TARGET_80387 && !TARGET_CMOVE - && reload_completed" - [(const_int 0)] -{ - ix86_split_fp_branch (GET_CODE (operands[0]), operands[1], operands[2], - operands[3], operands[4], operands[5]); - DONE; -}) - -;; The order of operands in *jcc__i387 is forced by combine in -;; simplify_comparison () function. Float operator is treated as RTX_OBJ -;; with a precedence over other operators and is always put in the first -;; place. Swap condition and operands to match ficom instruction. - -(define_insn "*jcc__i387" - [(set (pc) - (if_then_else - (match_operator:CCFP 0 "ix86_swapped_fp_comparison_operator" - [(match_operator:X87MODEF 1 "float_operator" - [(match_operand:SWI24 2 "nonimmediate_operand" "m")]) - (match_operand:X87MODEF 3 "register_operand" "f")]) - (label_ref (match_operand 4)) - (pc))) - (clobber (reg:CCFP FPSR_REG)) - (clobber (reg:CCFP FLAGS_REG)) - (clobber (match_scratch:HI 5 "=a"))] - "TARGET_80387 && !TARGET_CMOVE - && (TARGET_USE_MODE_FIOP - || optimize_function_for_size_p (cfun))" - "#") - -(define_split - [(set (pc) - (if_then_else - (match_operator:CCFP 0 "ix86_swapped_fp_comparison_operator" - [(match_operator:X87MODEF 1 "float_operator" - [(match_operand:SWI24 2 "memory_operand")]) - (match_operand:X87MODEF 3 "register_operand")]) - (match_operand 4) - (match_operand 5))) - (clobber (reg:CCFP FPSR_REG)) - (clobber (reg:CCFP FLAGS_REG)) - (clobber (match_scratch:HI 6))] - "TARGET_80387 && !TARGET_CMOVE - && reload_completed" - [(const_int 0)] -{ - ix86_split_fp_branch (swap_condition (GET_CODE (operands[0])), operands[3], - gen_rtx_FLOAT (GET_MODE (operands[1]), operands[2]), - operands[4], operands[5], operands[6]); - DONE; -}) ;; Unconditional and other jump instructions diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md index 4e023afb110..0917fad15d4 100644 --- a/gcc/config/i386/predicates.md +++ b/gcc/config/i386/predicates.md @@ -1387,19 +1387,6 @@ (match_operand 0 "comparison_operator") (match_operand 0 "ix86_trivial_fp_comparison_operator"))) -;; Same as above, but for swapped comparison used in *jcc__i387. -(define_predicate "ix86_swapped_fp_comparison_operator" - (match_operand 0 "comparison_operator") -{ - enum rtx_code code = GET_CODE (op); - bool ret; - - PUT_CODE (op, swap_condition (code)); - ret = ix86_fp_comparison_operator (op, mode); - PUT_CODE (op, code); - return ret; -}) - ;; Nearly general operand, but accept any const_double, since we wish ;; to be able to drop them into memory rather than have them get pulled ;; into registers. @@ -1423,10 +1410,6 @@ (define_predicate "plusminuslogic_operator" (match_code "plus,minus,and,ior,xor")) -;; Return true if this is a float extend operation. -(define_predicate "float_operator" - (match_code "float")) - ;; Return true for ARITHMETIC_P. (define_predicate "arith_or_logical_operator" (match_code "plus,mult,and,ior,xor,smin,smax,umin,umax,compare,minus,div, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index adf2425a67e..b85e93cafd0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2017-10-11 Uros Bizjak + + * gcc.target/i386/387-ficom-1.c: New test. + 2017-10-11 Jeff Law * gcc.dg/struct-layout-1_generate.c (generate_fields): Fix typo in diff --git a/gcc/testsuite/gcc.target/i386/387-ficom-1.c b/gcc/testsuite/gcc.target/i386/387-ficom-1.c new file mode 100644 index 00000000000..8c73ddcb2da --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/387-ficom-1.c @@ -0,0 +1,41 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target ia32 } */ +/* { dg-skip-if "" { *-*-* } { "-march=*" } { "-march=i386" } } */ +/* { dg-options "-O2 -march=i386 -ffast-math -masm=att" } */ + +extern short s; + +int test_f_s (short x) +{ + return (float)x > s; +} + +int test_d_s (short x) +{ + return (double)x < s; +} + +int test_ld_s (short x) +{ + return (long double)x == s; +} + +extern int i; + +int test_f_i (int x) +{ + return (float)i >= x; +} + +int test_d_i (int x) +{ + return (double)i <= x; +} + +int test_ld_i (int x) +{ + return (long double)i != x; +} + +/* { dg-final { scan-assembler-times "ficomps" 3 } } */ +/* { dg-final { scan-assembler-times "ficompl" 3 } } */ -- 2.30.2