This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] PR optimization/1823: -ftrapv issue in expand_divmod (take2)
- From: Roger Sayle <roger at eyesopen dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 4 Sep 2003 18:21:18 -0600 (MDT)
- Subject: [PATCH] PR optimization/1823: -ftrapv issue in expand_divmod (take2)
On Thu, 4 Sep 2003, Richard Henderson wrote:
> Unsigned multiplication only differs from signed multiplication
> when the inputs are smaller than the output. Which is not the
> case here.
>
> It's safe to change it.
The following patch survives bootstrap on i686-pc-linux-gnu, all languages
except treelang, with no new testsuite failures and it fixes PR opt/1823.
I would never have risked trying it if it were not for your suggestion,
but the clean bootstrap and regression suite can't be argued with.
Ok for mainline?
2003-09-04 Roger Sayle <roger@eyesopen.com>
Richard Henderson <rth@redhat.com>
PR optimization/1823
* expmed.c (expand_divmod <EXACT_DIV_EXPR>): Use an unsigned
multiplication to implement division by constant integer.
Index: expmed.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expmed.c,v
retrieving revision 1.140
diff -c -3 -p -r1.140 expmed.c
*** expmed.c 22 Aug 2003 06:45:13 -0000 1.140
--- expmed.c 4 Sep 2003 19:47:53 -0000
*************** expand_divmod (int rem_flag, enum tree_c
*** 3824,3830 ****
build_int_2 (pre_shift, 0), NULL_RTX, unsignedp);
quotient = expand_mult (compute_mode, t1,
gen_int_mode (ml, compute_mode),
! NULL_RTX, 0);
insn = get_last_insn ();
set_unique_reg_note (insn,
--- 3824,3830 ----
build_int_2 (pre_shift, 0), NULL_RTX, unsignedp);
quotient = expand_mult (compute_mode, t1,
gen_int_mode (ml, compute_mode),
! NULL_RTX, 1);
insn = get_last_insn ();
set_unique_reg_note (insn,
Roger
--
Roger Sayle, E-mail: roger@eyesopen.com
OpenEye Scientific Software, WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road, Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507. Fax: (+1) 505-473-0833