From a8bac9ab24d80842b398093d83096fbb3692cc47 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Mon, 22 Oct 2001 00:19:01 -0700 Subject: [PATCH] i386.c (ix86_expand_clear): New. * config/i386/i386.c (ix86_expand_clear): New. * config/i386/i386-protos.h: Declare it. * config/i386/i386.md (setcc peep2s): Use it. (movsi_xor): Unexport. From-SVN: r46404 --- gcc/ChangeLog | 7 +++++++ gcc/config/i386/i386-protos.h | 1 + gcc/config/i386/i386.c | 29 +++++++++++++++++++++++++++++ gcc/config/i386/i386.md | 12 +++--------- 4 files changed, 40 insertions(+), 9 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c5113b36591..3374a63be55 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2001-10-22 Richard Henderson + + * config/i386/i386.c (ix86_expand_clear): New. + * config/i386/i386-protos.h: Declare it. + * config/i386/i386.md (setcc peep2s): Use it. + (movsi_xor): Unexport. + 2001-10-22 Richard Henderson * flow.c (clear_log_links): Use free_INSN_LIST_list, not diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h index 111dc1616a7..edd5446ba33 100644 --- a/gcc/config/i386/i386-protos.h +++ b/gcc/config/i386/i386-protos.h @@ -106,6 +106,7 @@ extern const char *output_fp_compare PARAMS ((rtx, rtx*, int, int)); extern void i386_dwarf_output_addr_const PARAMS ((FILE*, rtx)); extern rtx i386_simplify_dwarf_addr PARAMS ((rtx)); +extern void ix86_expand_clear PARAMS ((rtx)); extern void ix86_expand_move PARAMS ((enum machine_mode, rtx[])); extern void ix86_expand_binary_operator PARAMS ((enum rtx_code, enum machine_mode, rtx[])); diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 17319890eb7..691a3979fea 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -6662,6 +6662,35 @@ ix86_output_addr_diff_elt (file, value, rel) ASM_LONG, LPREFIX, value); } +/* Generate either "mov $0, reg" or "xor reg, reg", as appropriate + for the target. */ + +void +ix86_expand_clear (dest) + rtx dest; +{ + rtx tmp; + + /* We play register width games, which are only valid after reload. */ + if (!reload_completed) + abort (); + + /* Avoid HImode and its attendant prefix byte. */ + if (GET_MODE_SIZE (GET_MODE (dest)) < 4) + dest = gen_rtx_REG (SImode, REGNO (dest)); + + tmp = gen_rtx_SET (VOIDmode, dest, const0_rtx); + + /* This predicate should match that for movsi_xor and movdi_xor_rex64. */ + if (reload_completed && (!TARGET_USE_MOV0 || optimize_size)) + { + rtx clob = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (CCmode, 17)); + tmp = gen_rtx_PARALLEL (VOIDmode, gen_rtvec (2, tmp, clob)); + } + + emit_insn (tmp); +} + void ix86_expand_move (mode, operands) enum machine_mode mode; diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index efede44cda1..803a0eb2664 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -1711,7 +1711,7 @@ [(set_attr "type" "pop") (set_attr "mode" "SI")]) -(define_insn "movsi_xor" +(define_insn "*movsi_xor" [(set (match_operand:SI 0 "register_operand" "=r") (match_operand:SI 1 "const0_operand" "i")) (clobber (reg:CC 17))] @@ -13277,10 +13277,7 @@ { operands[4] = gen_rtx_REG (GET_MODE (operands[0]), 17); operands[5] = gen_rtx_REG (QImode, REGNO (operands[3])); - if (HAVE_movsi_xor) - emit_insn (gen_movsi_xor (operands[3], const0_rtx)); - else - emit_insn (gen_movsi (operands[3], const0_rtx)); + ix86_expand_clear (operands[3]); }) ;; Similar, but match zero_extendhisi2_and, which adds a clobber. @@ -13302,10 +13299,7 @@ { operands[4] = gen_rtx_REG (GET_MODE (operands[0]), 17); operands[5] = gen_rtx_REG (QImode, REGNO (operands[3])); - if (HAVE_movsi_xor) - emit_insn (gen_movsi_xor (operands[3], const0_rtx)); - else - emit_insn (gen_movsi (operands[3], const0_rtx)); + ix86_expand_clear (operands[3]); }) ;; Call instructions.