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

[Bug target/48077] [Code Improvement] Poor expansion of multiply on powerpc64-linux


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

--- Comment #4 from Michael Meissner <meissner at gcc dot gnu.org> 2011-03-11 20:43:20 UTC ---
It depends on what the default cpu is for the system.  If you say -mcpu=power4,
-mcpu=power5, or -mcpu=power7, it generates code similar to what XLC generates
with mulhw to get the recrip. and a mulli:

demonstrate:
        lis 9,values@ha
        slwi 3,3,2
        lwz 11,values@l(9)
        lis 0,0x1062
        ori 0,0,19923
        lwzx 9,11,3
        lis 11,hash_table@ha
        lwz 8,hash_table@l(11)
        mulhw 0,9,0
        srawi 10,9,31
        srawi 0,0,6
        subf 0,10,0
        mulli 0,0,1000
        subf 9,0,9
        slwi 9,9,2
        lwzx 3,8,9
        blr

If you say -mcpu=power6 the mulli is replaced by shifts and adds, similar to
what XLC generates.

demonstrate:
        lis 11,values@ha
        slwi 3,3,2
        lwz 9,values@l(11)
        lis 11,hash_table@ha
        add 9,9,3
        lwz 8,hash_table@l(11)
        lwz 10,0(9)
        lis 9,0x1062
        ori 9,9,19923
        mulhw 9,10,9
        srawi 0,10,31
        srawi 9,9,6
        subf 9,0,9
        slwi 11,9,2
        slwi 0,9,7
        subf 0,11,0
        add 0,0,9
        slwi 0,0,3
        subf 10,0,10
        slwi 10,10,2
        add 8,8,10
        lwz 3,0(8)
        blr


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