This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Add new target-hook truncated_to_mode
- From: Adam Nemet <anemet at sonic dot net>
- To: Paolo Bonzini <paolo dot bonzini at lu dot unisi dot ch>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Richard Sandiford <richard at codesourcery dot com>
- Date: Mon, 13 Mar 2006 00:02:32 -0800
- Subject: Re: [PATCH] Add new target-hook truncated_to_mode
- References: <17427.34832.666999.793894@localhost.localdomain> <441524A5.5070205@lu.unisi.ch>
Paolo Bonzini writes:
> > +mips_truncated_to_mode (enum machine_mode mode, rtx x)
> > +{
> > + gcc_assert (!TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (mode),
> > + GET_MODE_BITSIZE (GET_MODE (x)))
> > + && GET_MODE (x) == DImode);
> > +
> > + return num_sign_bit_copies (x, GET_MODE (x)) >= 33;
>
> ...
>
> bool
> truncated_to_mode (enum machine_mode mode, rtx x)
> {
> if (REG_P (x) && rtl_hooks.reg_truncated_to_mode (mode, x))
> return true;
>
> gcc_assert (!TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (mode),
> GET_MODE_BITSIZE (GET_MODE (x)));
> return num_sign_bit_copies (x, GET_MODE (x)) >
> GET_MODE_BITSIZE (GET_MODE (x)) - GET_MODE_BITSIZE (mode);
> }
>
> In the MIPS case, you would have n_s_b_c (x, GET_MODE (x)) > 64 - 32.
This wouldn't work for DI->HI truncation for example. There too only
the upper 33 bits have to match for the TRUNCATE to be unnecessary.
See comment around truncsdi in mips.md.
Adam