This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch RFA] SH: Fix PR target/29599
Alexandre Oliva <aoliva@redhat.com> wrote:
> There's trunc_int_for_mode() for this kind of sign extension.
> However, I don't think a target-specific patch is the correct
> approach for this bug, it is treating the symptom; the actual bug is
> that the constant is either generated or narrowed without proper sign
> extension.
I'd tested the patch for eliminate_regs_in_insn in the comment
#2 of the PR:
--- ORIG/trunk/gcc/reload1.c 2006-11-19 10:41:46.000000000 +0900
+++ LOCAL/trunk/gcc/reload1.c 2006-12-04 08:29:43.000000000 +0900
@@ -3093,7 +3093,15 @@ eliminate_regs_in_insn (rtx insn, int re
if (ep->from_rtx == reg && ep->can_eliminate)
{
rtx to_rtx = ep->to_rtx;
+ unsigned int width = GET_MODE_BITSIZE (GET_MODE (reg));
+
offset += ep->offset;
+ if (width < HOST_BITS_PER_WIDE_INT)
+ {
+ offset &= ((HOST_WIDE_INT) 1 << width) - 1;
+ if (offset & ((HOST_WIDE_INT) 1 << (width - 1)))
+ offset |= ((HOST_WIDE_INT) (-1) << width);
+ }
if (GET_CODE (XEXP (plus_cst_src, 0)) == SUBREG)
to_rtx = gen_lowpart (GET_MODE (XEXP (plus_cst_src, 0)),
Does it make sense? If it seems to be the right thing, I'd like
to rewrite it with trunc_int_for_mode and propose it to the list.
Regards,
kaz