[Bug target/54429] New: [SH] SImode values get ferried through FPUL and FP regs for -O0

olegendo at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Aug 30 22:26:00 GMT 2012


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

             Bug #: 54429
           Summary: [SH] SImode values get ferried through FPUL and FP
                    regs for -O0
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: target
        AssignedTo: olegendo@gcc.gnu.org
        ReportedBy: olegendo@gcc.gnu.org
                CC: kkojima@gcc.gnu.org
            Target: sh*-*-*


I've noticed that, for some reason, when compiling code with -O0 SImode values
get ferried through FPUL reg and FP regs, like .. 

        lds     r1,fpul
        fsts    fpul,fr1
        mov     r7,r4
        flds    fr1,fpul
        sts     fpul,r5

.. which is really just:
        mov     r1,r5
        mov     r7,r4

In sh_hard_regno_mode_ok, I've tried doing:

Index: gcc/config/sh/sh.c
===================================================================
--- gcc/config/sh/sh.c    (revision 190780)
+++ gcc/config/sh/sh.c    (working copy)
@@ -11706,6 +11706,9 @@
   if (FP_REGISTER_P (regno) && mode == SFmode)
     return true;

+  if (FP_REGISTER_P (regno) && GET_MODE_CLASS (mode) != MODE_FLOAT)
+    return false;
+
   if (mode == V2SFmode)
     {
       if (((FP_REGISTER_P (regno) && (regno - FIRST_FP_REG) % 2 == 0)

.. and it makes the confusing FP reg usage go away.  Somehow, I don't
understand why it would make sense to allow any integer modes in FP regs on SH.
 No useful integer operations can be done with integer values in FP regs
anyway.  The only purpose that I see, is to allow spilling of GP regs to FP
regs, which doesn't seem beneficial.

I've checked CSiBE results with the fix above.  It causes a few increases and
decreases in the teem lib.  The increases are, because GP regs are not spilled
to FP regs anymore and have to go to the stack, which causes some unlucky
displacement address changes.  The decreases are because of the same, but where
displacement addresses are lucky.  Also, weird cases disappear where FP regs
are pushed/popped in a function but are otherwise unused.

Kaz, do you happen to know why the sh_hard_regno_mode_ok function is the way it
is?  I think The FP reg check after the V16SFmode check ...

if (FP_REGISTER_P (regno))
    {
      if (mode == SFmode
      || mode == SImode
     ....

would also become obsolete if the change above was applied?



More information about the Gcc-bugs mailing list