[PATCH] hppa: PR middle-end/87256: Improved hppa_rtx_costs avoids synth_mult madness.

Roger Sayle roger@nextmovesoftware.com
Wed Aug 26 11:19:49 GMT 2020

Hi Dave,

> This change is also fine.
> The gcc.target/hppa/shadd-2.c test now fails because there are two
additional sh1add instructions.
> However, the total number of instructions is the same as before.

Just to be on the safe side, I took a deeper look into this.
We're now generating a slightly different sequence for multiply by 87.

        zdep %r28,28,29,%r20            ; r20 = r28*8
        ldo RR'default_target_regs-$global$(%r1),%r19
        sub %r20,%r28,%r20              ; r20 = r28*7
        sh2addl %r20,%r28,%r20          ; r20 = r28*29
        sh2addl %r20,%r19,%r19          ; r20 = addr+r28*116
        sub %r19,%r20,%r19              ; r20 = addr+r28*87

        sh2addl %r28,%r28,%r19          ; r19 = r28*5
        ldo RR'default_target_regs-$global$(%r1),%r1
        sh2addl %r19,%r28,%r19          ; r19 = r28*21
        sh1addl %r19,%r28,%r19          ; r19 = r28*43
        sh1addl %r19,%r28,%r19          ; r19 = r28*87
        addl %r1,%r19,%r1               ; r1 = addr+r28*87

As you point out, both sequences have exactly the same length and rtx_costs.
I suspect the middle-end has a minor preference for simple shifts and adds.
If shadd-2.c is there to check we make use of sh?add instructions, then
making even more use of them now.

I agree it's reasonable to increase the scan-assembler-times count for this


More information about the Gcc-patches mailing list