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, combine] Try REG_EQUAL for nonzero_bits


On 02/09/2015 07:00 PM, Thomas Preud'homme wrote:
And this is part 2.

From: gcc-patches-owner@gcc.gnu.org [mailto:gcc-patches-
owner@gcc.gnu.org] On Behalf Of Eric Botcazou

Once this is done, the same thing needs to be applied to XEXP
(reg_equal, 0)
before it is sent to nonzero_bits.


-	  /* Don't call nonzero_bits if it cannot change anything.  */
-	  if (rsp->nonzero_bits != ~(unsigned HOST_WIDE_INT) 0)
-	    rsp->nonzero_bits |= nonzero_bits (src, nonzero_bits_mode);
  	  num = num_sign_bit_copies (SET_SRC (set), GET_MODE (x));
  	  if (rsp->sign_bit_copies == 0

  	      || rsp->sign_bit_copies > num)

  	    rsp->sign_bit_copies = num;
+
+	  /* Don't call nonzero_bits if it cannot change anything.  */
+	  if (rsp->nonzero_bits != ~(unsigned HOST_WIDE_INT) 0)
+	    update_rsp_from_reg_equal (rsp, insn, src, x);

Can't we improve on this?  rsp->sign_bit_copies is modified both here
and in
update_rsp_from_reg_equal, but rsp->nonzero_bits is modified only in
the
latter function.  There is no reason for this discrepancy, so they ought to
be
handled the same way, either entirely here or entirely in the function.

So I moved all the handling inside the new function and also added a check
before calling num_sign_bit_copies about whether it would give any more
information to be consistent with what is done for nonzero_bits.

ChangeLog entry is as follows:

2015-02-09  Thomas Preud'homme  <thomas.preudhomme@arm.com>

         * combine.c i(set_nonzero_bits_and_sign_copies): Split code updating
         rsp->sign_bit_copies and rsp->nonzero_bits into ...
         (update_rsp_from_reg_equal): This.  Also use REG_EQUAL note on src if
         present to get more accurate information about the number of sign bit
         copies and non zero bits.
Do you have a testcase where this change can result in better generated code. If so please add that testcase. It's OK if it's ARM specific.

OK with a testcase.

jeff


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