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: [RFC, tentative patch] Adjust cost for conversion expression


On 11/24/2016 03:58 AM, Pitchumani Sivanupandi wrote:
GCC inlines small functions if the code size after expansion is not
excedded.
For test case (inline.c, avr-gcc -Os -S inline.c) code size become
higher if
'func2' is inlined. It happens because the CONVERT_EXPR/ NOP_EXPR are
considered
as zero cost expression.

Few conversions will cost additional instructions. For targets like AVR
it will cost considerably as it's register size is just one byte.

Attached the tentative patch that changes the CONVERT_EXPR/ NOP_EXPR cost
to 1 if the LHS is bigger than RHS and target's word_mode.

Is this Ok?

Would it be reasonable if cost evaluated as below instead of constant 1?
  if (LHS PRECISION > RHS PRECISION)
    cost = LHS_PRECISION / word_mode - 1
  else
    cost = 0

Built GCC for native with bootstrap enabled. No issues.
My high level worry here is that this introduces a target dependency into the early part of the tree optimization pipeline (the test against word_mode).

I'd be more open to giving a cost to any widening conversion. That kind of change might have a wide reaching impact though.

jeff


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