This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Improved signed integer remainder by power of two
- From: Richard Henderson <rth at redhat dot com>
- To: Roger Sayle <roger at eyesopen dot com>
- Cc: gcc-patches at gcc dot gnu dot org, Steven Bosscher <stevenb at suse dot de>
- Date: Sun, 27 Jun 2004 22:51:56 -0700
- Subject: Re: [PATCH] Improved signed integer remainder by power of two
- References: <Pine.LNX.4.44.0406271845400.2779-100000@www.eyesopen.com>
On Sun, Jun 27, 2004 at 07:23:31PM -0600, Roger Sayle wrote:
> + && ashr_optab->handlers[mode].insn_code != CODE_FOR_nothing)
> + {
> + rtx signmask = expand_binop (mode, ashr_optab, op0,
> + GEN_INT (GET_MODE_BITSIZE (mode) - 1),
> + NULL_RTX, 0, OPTAB_LIB_WIDEN);
> + signmask = force_reg (mode, signmask);
I might think this would be better as
emit_store_flag (NULL_RTX, LT, op0, const0_rtx, mode, 0, -1);
Doh, except emit_store_flag does not, as I hoped, check to see
which of the following is cheapest.
(neg:SI (lt:SI x 0)) // STORE_FLAG_VALUE = 1
(lt:SI x 0) // STORE_FLAG_VALUE = -1
(ashiftrt:SI x 31)
Still, without updating emit_store_flag, you should get the same
results you do now, and it consolidates that knowledge should it
ever be added.
Otherwise it looks good.
r~