------- Comment #1 from ubizjak at gmail dot com  2007-01-21 11:38 -------
(In reply to comment #0)

> gcc with -Os -fno-PIC generates:
>         movb    $38, (%ebx,%edx)        # 45    *movqi_1/7      [length = 4]
>         leal    (%ebx,%edx), %eax       # 122   *lea_1  [length = 3]
>         movb    $108, 1(%eax)   # 48    *movqi_1/7      [length = 4]
>         movb    $116, 2(%eax)   # 50    *movqi_1/7      [length = 4]
>         movb    $59, 3(%eax)    # 52    *movqi_1/7      [length = 4]
>         addl    $4, %edx        # 54    *addsi_1/1      [length = 3]
> 
>         movb    $38, (%ebx,%edx)        # 61    *movqi_1/7      [length = 4]
>         movb    $103, 1(%edx,%ebx)      # 64    *movqi_1/7      [length = 5]
>         movb    $116, 2(%edx,%ebx)      # 67    *movqi_1/7      [length = 5]
>         movb    $59, 3(%edx,%ebx)       # 70    *movqi_1/7      [length = 5]
>         addl    $4, %edx        # 71    *addsi_1/1      [length = 3]

I think this is due to address cost calculation, which returns the same cost
for   different complex addressing modes. Current costs are (taken from ivopts
tree dump):

Address costs:
  index costs 2
  sym + index costs 1
  var + index costs 3
  sym + var + index costs 2
  cst + index costs 1
  sym + cst + index costs 1
  var + cst + index costs 2
  sym + var + cst + index costs 2
  rat * index costs 2
  sym + rat * index costs 1
  var + rat * index costs 3
  sym + var + rat * index costs 2
  cst + rat * index costs 1
  sym + cst + rat * index costs 1
  var + cst + rat * index costs 2
  sym + var + cst + rat * index costs 2

Unfortunatelly, changing address costs has tendency to create worse code in
other places (for example - offset is moved into a register and reg+reg access
is used insted of reg+offset access).

> The second is the same size as the first at the moment, but should be
> transformed into the same thing.

If they are the same size (and there is no speed impact), there is actually no
point to expect that they should compile to the same thing.

BTW: similar effect of address cost can be seen in PR/24669.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30517

Reply via email to