This is the mail archive of the gcc@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]

Analysis try (was: Re: rs6000: Trivial code generation stupidity)


On 17 Dec, David Edelsohn wrote:

> 	Also, you can look at the output from intermediate passes and see
> where gcc-2.95 chose the output in the correct register while gcc-3.1
> introduces the extra copies.  Track down which phase in gcc-3.1 is not
> collapsing the register copies or why it is introducing register
> copies.

You asked for it but be warned that this is the first time I try to
really analyse RTL and thus my analysis could be completely bogus and/or
wrong.

Consider:
int 
foo (int a, int b)
{
  return b+1;
}

gcc 3.1 produces:
foo:
        addi 4,4,1       # 15   *addsi3_internal1/2     [length = 4]
        mr 3,4   # 24   *movsi_internal1/1      [length = 4]
        blr      # 36   *return_internal_si     [length = 4]

Here we can see that the register move comes from insn 24.
Analysing the RTL of all passes between gcc 2.95.3 and gcc 3.1 shows
that in the combine pass gcc 2.95.3 merges the plus:SI and the move
into 
(insn 14 12 15 (set (reg/i:SI 3 r3)
        (plus:SI (reg:SI 4 r4)
            (const_int 1 [0x1]))) 52 {*addsi3_internal1} (nil)
    (expr_list:REG_DEAD (reg:SI 4 r4)
        (nil)))

while gcc 3.1 keeps them in seperate insns using a virtual register for
the result of the plus:SI:
(insn 15 7 20 (set (reg:SI 118)
        (plus:SI (reg/v:SI 117)
            (const_int 1 [0x1]))) 36 {*addsi3_internal1} (insn_list 6 (nil))
    (expr_list:REG_DEAD (reg/v:SI 117)
        (nil)))

(insn 24 20 27 (set (reg/i:SI 3 r3)
        (reg:SI 118)) 295 {*movsi_internal1} (insn_list 15 (nil))
    (expr_list:REG_DEAD (reg:SI 118)
        (nil)))

So it seems that combine broke because it fails to recognize the
opportunity to get rid of a virtual register.

The bottom lines of the combine pass outputs are
2.95.3:
;; Combiner totals: 3 attempts, 3 substitutions (0 requiring new space),
;; 2 successes.

3.1:
;; Combiner totals: 0 attempts, 0 substitutions (0 requiring new space),
;; 0 successes.

If anyone wants to see the outputs of the intermediate passes feel free
to contact me and you'll get them.

--
Servus,
       Daniel


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