optimization, powerpc style

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

 



Hi,

While trying to figure out why the PowerMac mesh scsi driver will work
when compiled with 4.1.2 but not with 4.3.5 I noticed some strange
behavior with literal strings.

#include <stdio.h>

const char *getMsg(unsigned int u)
{
        const char *p;

        switch(u)
        {
                case 0:
                        p="This is message 0"; break;
                case 1:
                        p="This is message 1"; break;
                case 2:
                        p="This is message 2"; break;
                case 3:
                        p="This is message 3"; break;
                case 4:
                        p="This is message 4"; break;
                case 5:
                        p="This is message 5"; break;
                default:
                        p=NULL;
        }

        return p;
}

This function when compiled with 3.4.6 produces pretty good code.
4.3.5 produces lesser good code. Can someone suggest what I search the
bug database for to see if this has been reported and what the status
is? Is it PowerPC specific?

In both the 4.2.4 and 4.3.5 versions of mesh, the mesh_start() routine
has a lengthy list of register assignments near the start of the
routine:

.L241:
        lis 9,.LANCHOR0@ha       # tmp459,
        lis 11,.LC47@ha  # tmp461,
        la 23,.LANCHOR0@l(9)     # tmp460,, tmp459
        lis 9,.LC48@ha   # tmp463,
        la 19,.LC47@l(11)        # tmp462,, tmp461
        la 18,.LC48@l(9)         # tmp464,, tmp463
        lis 11,.LC16@ha  # tmp465,
        lis 9,.LC50@ha   # tmp467,
        la 17,.LC16@l(11)        # tmp466,, tmp465
        la 22,.LC50@l(9)         # tmp468,, tmp467
        lis 11,.LC51@ha  # tmp469,
        lis 9,.LC57@ha   # tmp471,
        la 21,.LC51@l(11)        # tmp470,, tmp469
        la 20,.LC57@l(9)         # tmp472,, tmp471
        lis 11,.LC58@ha  # tmp473,
        lis 9,.LC59@ha   # tmp475,
        la 16,.LC58@l(11)        # tmp474,, tmp473
        la 15,.LC59@l(9)         # tmp476,, tmp475
        lis 11,.LC60@ha  # tmp477,
        lis 9,.LC53@ha   # tmp480,
        la 14,.LC60@l(11)        # tmp478,, tmp477
        la 24,.LC53@l(9)         # tmp482,, tmp480

Later, when one of these is used you'll see:

        mr 3,19  #, tmp462
        mr 4,31  #, cmd
        mr 6,28  #, id
        bl printk        #

for .LC47, which is "<4>mesh_start: %p ser=%lu tgt=%d cmd="

These all end up in:

.section        .rodata.str1.4,"aMS",@progbits,1

and will have addresses close to each other, right? I don't understand
why they can't do something like:

lis 15,.LANCHOR0@ha
la 15,.LANCHOR0@l(15)

and then do something like:

la 3,<some offset>(15)

when each string is used. What am I missing?

The above register loads also result in:

        stmw 14,8(1)     #,
and
        lmw 14,8(1)      #,

for 4.3.5. A smaller set is saved in 4.1.2

        stmw 25,20(1)    #,
and
        lmw 25,20(1)     #,

Won't this lead to unneeded memory traffic and/or cache churning?

kevin

P.S.:  For all those who send email from their Blackberry's and iphones:

Sent from my 33 MHz 386 using Firefox 2!

Attachment: gcctest1-3.4.6.s
Description: Binary data

Attachment: gcctest1-4.3.5.s
Description: Binary data


[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