From 7fecf2c7dbdd6b13dfce378a66d532c7411ec49f Mon Sep 17 00:00:00 2001 From: Andrew Pinski Date: Fri, 31 Aug 2007 15:45:43 -0700 Subject: [PATCH] optabs.c (prepare_float_lib_cmp): Use libgcc_cmp_return_mode instead of word_mode. 2007-08-31 Andrew Pinski * optabs.c (prepare_float_lib_cmp): Use libgcc_cmp_return_mode instead of word_mode. * config/dfp-bit.h: Likewise. * config/fp-bit.h: Likewise. * config/spu/spu.c (spu_libgcc_cmp_return_mode): New function. (spu_libgcc_shift_count_mode): New function. (TARGET_LIBGCC_CMP_RETURN_MODE): Define. (TARGET_LIBGCC_SHIFT_COUNT_MODE): Define. From-SVN: r128005 --- gcc/ChangeLog | 13 +++++++++++++ gcc/config/dfp-bit.h | 4 ++-- gcc/config/fp-bit.h | 4 ++-- gcc/config/spu/spu.c | 31 ++++++++++++++++++++++++++++++- gcc/optabs.c | 19 ++++++++++--------- 5 files changed, 57 insertions(+), 14 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bed7f667d02..8edd7f4d5e9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2007-08-31 Andrew Pinski + + * optabs.c (prepare_float_lib_cmp): Use + libgcc_cmp_return_mode instead of word_mode. + * config/dfp-bit.h: Likewise. + * config/fp-bit.h: Likewise. + * config/spu/spu.c (spu_libgcc_cmp_return_mode): + New function. + (spu_libgcc_shift_count_mode): New function. + (TARGET_LIBGCC_CMP_RETURN_MODE): Define. + (TARGET_LIBGCC_SHIFT_COUNT_MODE): Define. + 2007-08-31 Joseph Myers * tree-pretty-print.c: Include output.h. @@ -39,6 +51,7 @@ split out from expand_binop. (avoid_expensive_constant): New function. (expand_binop_directly): Remove commutative_op argument and + (expand_binop_directly): Remove commutative_op argument and call cummutative_optab_p instead. Do not change op0 or op1 when swapping xop0 and xop1. Apply avoid_expensive_constant to each argument after potential swapping. Enforce the diff --git a/gcc/config/dfp-bit.h b/gcc/config/dfp-bit.h index 5238a2b3765..dfbf4f48338 100644 --- a/gcc/config/dfp-bit.h +++ b/gcc/config/dfp-bit.h @@ -454,9 +454,9 @@ typedef unsigned int USItype __attribute__ ((mode (SI))); typedef unsigned int UDItype __attribute__ ((mode (DI))); /* The type of the result of a decimal float comparison. This must - match `word_mode' in GCC for the target. */ + match `__libgcc_cmp_return__' in GCC for the target. */ -typedef int CMPtype __attribute__ ((mode (word))); +typedef int CMPtype __attribute__ ((mode (__libgcc_cmp_return__))); /* Prototypes. */ diff --git a/gcc/config/fp-bit.h b/gcc/config/fp-bit.h index 0f03f87ee1a..5f9082cd301 100644 --- a/gcc/config/fp-bit.h +++ b/gcc/config/fp-bit.h @@ -108,9 +108,9 @@ typedef int TItype __attribute__ ((mode (TI))); #endif /* The type of the result of a floating point comparison. This must - match `word_mode' in GCC for the target. */ + match `__libgcc_cmp_return__' in GCC for the target. */ #ifndef CMPtype -typedef int CMPtype __attribute__ ((mode (word))); +typedef int CMPtype __attribute__ ((mode (__libgcc_cmp_return__))); #endif typedef unsigned int UHItype __attribute__ ((mode (HI))); diff --git a/gcc/config/spu/spu.c b/gcc/config/spu/spu.c index eda0de03813..7fcc9429310 100644 --- a/gcc/config/spu/spu.c +++ b/gcc/config/spu/spu.c @@ -174,6 +174,12 @@ static int cpat_info(unsigned char *arr, int size, int *prun, int *pstart); static enum immediate_class classify_immediate (rtx op, enum machine_mode mode); +static enum machine_mode +spu_libgcc_cmp_return_mode (void); + +static enum machine_mode +spu_libgcc_shift_count_mode (void); + /* Built in types. */ tree spu_builtin_types[SPU_BTI_MAX]; @@ -275,6 +281,12 @@ const struct attribute_spec spu_attribute_table[]; #undef TARGET_VECTOR_ALIGNMENT_REACHABLE #define TARGET_VECTOR_ALIGNMENT_REACHABLE spu_vector_alignment_reachable +#undef TARGET_LIBGCC_CMP_RETURN_MODE +#define TARGET_LIBGCC_CMP_RETURN_MODE spu_libgcc_cmp_return_mode + +#undef TARGET_LIBGCC_SHIFT_COUNT_MODE +#define TARGET_LIBGCC_SHIFT_COUNT_MODE spu_libgcc_shift_count_mode + struct gcc_target targetm = TARGET_INITIALIZER; void @@ -5502,4 +5514,21 @@ spu_init_expanders (void) * expanding the prologue. */ if (cfun) REGNO_POINTER_ALIGN (HARD_FRAME_POINTER_REGNUM) = 8; -} +} + +static enum machine_mode +spu_libgcc_cmp_return_mode (void) +{ + +/* For SPU word mode is TI mode so it is better to use SImode + for compare returns. */ + return SImode; +} + +static enum machine_mode +spu_libgcc_shift_count_mode (void) +{ +/* For SPU word mode is TI mode so it is better to use SImode + for shift counts. */ + return SImode; +} diff --git a/gcc/optabs.c b/gcc/optabs.c index 6b292638c89..97319714fa5 100644 --- a/gcc/optabs.c +++ b/gcc/optabs.c @@ -4232,10 +4232,11 @@ prepare_float_lib_cmp (rtx *px, rtx *py, enum rtx_code *pcomparison, rtx x = *px; rtx y = *py; enum machine_mode orig_mode = GET_MODE (x); - enum machine_mode mode; + enum machine_mode mode, cmp_mode; rtx value, target, insns, equiv; rtx libfunc = 0; bool reversed_p = false; + cmp_mode = targetm.libgcc_cmp_return_mode (); for (mode = orig_mode; mode != VOIDmode; @@ -4274,14 +4275,14 @@ prepare_float_lib_cmp (rtx *px, rtx *py, enum rtx_code *pcomparison, condition can be determined at compile-time. */ if (comparison == UNORDERED) { - rtx temp = simplify_gen_relational (NE, word_mode, mode, x, x); - equiv = simplify_gen_relational (NE, word_mode, mode, y, y); - equiv = simplify_gen_ternary (IF_THEN_ELSE, word_mode, word_mode, + rtx temp = simplify_gen_relational (NE, cmp_mode, mode, x, x); + equiv = simplify_gen_relational (NE, cmp_mode, mode, y, y); + equiv = simplify_gen_ternary (IF_THEN_ELSE, cmp_mode, cmp_mode, temp, const_true_rtx, equiv); } else { - equiv = simplify_gen_relational (comparison, word_mode, mode, x, y); + equiv = simplify_gen_relational (comparison, cmp_mode, mode, x, y); if (! FLOAT_LIB_COMPARE_RETURNS_BOOL (mode, comparison)) { rtx true_rtx, false_rtx; @@ -4321,18 +4322,18 @@ prepare_float_lib_cmp (rtx *px, rtx *py, enum rtx_code *pcomparison, default: gcc_unreachable (); } - equiv = simplify_gen_ternary (IF_THEN_ELSE, word_mode, word_mode, + equiv = simplify_gen_ternary (IF_THEN_ELSE, cmp_mode, cmp_mode, equiv, true_rtx, false_rtx); } } start_sequence (); value = emit_library_call_value (libfunc, NULL_RTX, LCT_CONST, - word_mode, 2, x, mode, y, mode); + cmp_mode, 2, x, mode, y, mode); insns = get_insns (); end_sequence (); - target = gen_reg_rtx (word_mode); + target = gen_reg_rtx (cmp_mode); emit_libcall_block (insns, target, value, equiv); if (comparison == UNORDERED @@ -4341,7 +4342,7 @@ prepare_float_lib_cmp (rtx *px, rtx *py, enum rtx_code *pcomparison, *px = target; *py = const0_rtx; - *pmode = word_mode; + *pmode = cmp_mode; *pcomparison = comparison; *punsignedp = 0; }