+2004-08-09 Roger Sayle <roger@eyesopen.com>
+
+ * expmed.c (sdiv_pow2_cheap, smod_pow2_cheap): Change type to bool.
+ (init_expmed): Fix potential overrun problem with "all.reg".
+ (expand_sdiv2_pow2): Add an alternate implementation for signed
+ division, if the target provides a suitable conditional move insn.
+
2004-08-09 Paul Brook <paul@codesourcery.com>
Richard Henderson <rth@redhat.com>
Usually, this will mean that the MD file will emit non-branch
sequences. */
-static int sdiv_pow2_cheap[NUM_MACHINE_MODES];
-static int smod_pow2_cheap[NUM_MACHINE_MODES];
+static bool sdiv_pow2_cheap[NUM_MACHINE_MODES];
+static bool smod_pow2_cheap[NUM_MACHINE_MODES];
#ifndef SLOW_UNALIGNED_ACCESS
#define SLOW_UNALIGNED_ACCESS(MODE, ALIGN) STRICT_ALIGNMENT
{
struct
{
- struct rtx_def reg;
+ struct rtx_def reg; rtunion reg_fld[2];
struct rtx_def plus; rtunion plus_fld1;
struct rtx_def neg;
struct rtx_def udiv; rtunion udiv_fld1;
return expand_shift (RSHIFT_EXPR, mode, temp, shift, NULL_RTX, 0);
}
+#ifdef HAVE_conditional_move
+ if (BRANCH_COST >= 2)
+ {
+ rtx temp2;
+
+ start_sequence ();
+ temp2 = copy_to_mode_reg (mode, op0);
+ temp = expand_binop (mode, add_optab, temp2, GEN_INT (d-1),
+ NULL_RTX, 0, OPTAB_LIB_WIDEN);
+ temp = force_reg (mode, temp);
+
+ /* Construct "temp2 = (temp2 < 0) ? temp : temp2". */
+ temp2 = emit_conditional_move (temp2, LT, temp2, const0_rtx,
+ mode, temp, temp2, mode, 0);
+ if (temp2)
+ {
+ rtx seq = get_insns ();
+ end_sequence ();
+ emit_insn (seq);
+ return expand_shift (RSHIFT_EXPR, mode, temp2, shift, NULL_RTX, 0);
+ }
+ end_sequence ();
+ }
+#endif
+
if (BRANCH_COST >= 2)
{
int ushift = GET_MODE_BITSIZE (mode) - logd;