This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add new target-hook truncated_to_mode



+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;

I may be wrong as I still have to understand the magic of TRUNCATE, but I don't think a target hook is necessary, as this logic is completely generic as far as I can tell. Why not this:


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.

Paolo


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]