Confused by the annotation in should_replace_address, a mistake ???

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Here is the code in fwprop.c:

/* OLD is a memory address.  Return whether it is good to use NEW instead,
   for a memory access in the given MODE.  */

static bool
should_replace_address (rtx old_rtx, rtx new_rtx, enum machine_mode mode,
			addr_space_t as, bool speed)
{
  int gain;

  if (rtx_equal_p (old_rtx, new_rtx)
      || !memory_address_addr_space_p (mode, new_rtx, as))
    return false;

  /* Copy propagation is always ok.  */
  if (REG_P (old_rtx) && REG_P (new_rtx))
    return true;

*  /* Prefer the new address if it is less expensive.  */
  gain = (address_cost (old_rtx, mode, as, speed)
	  - address_cost (new_rtx, mode, as, speed));

  /* If the addresses have equivalent cost, prefer the new address
     if it has the highest `set_src_cost'.  That has the potential of
     eliminating the most insns without additional costs, and it
     is the same that cse.c used to do.  */
  if (gain == 0)
    gain = set_src_cost (new_rtx, speed) - set_src_cost (old_rtx, speed);

  return (gain > 0);*
}

According to the annotation, the 'return (gain > 0)' shouldn't be 'return
(gain >= 0)' ?

Here is the case for forward_addr.
insn set r155
           plus r167 + 32
insn set mem (155)
           r188
insn set mem (plus r155 + 8)
           r189
......

If it is handled by the original code,
the result will be:
insn set r155
           plus r167 + 32
insn set mem (r167 + 32)
           r188
insn set mem (plus r155 + 8)
           r189

However it is expected to be:
insn set mem (r167 + 32)
           r188
insn set mem (plus r167 + 40)
           r189    

As the cost of 'addr r155' + 8 is equal to 'addr r167 + 40', so I think that
we should preffer to take the new addr, technically will be profitable ???


Brs,
       Peter Xu.

           



-----
Dying in the sun.
--
View this message in context: http://gcc.1065356.n5.nabble.com/Confused-by-the-annotation-in-should-replace-address-a-mistake-tp1001116.html
Sent from the gcc - Help mailing list archive at Nabble.com.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux