[PATCH] Fix floating point register use on S/390

Ulrich Weigand Ulrich.Weigand@de.ibm.com
Tue Jun 11 08:06:00 GMT 2002


Hello,

this patch fixes a regression when building the Linux kernel
on gcc 3.1 or later.  The problem is that we've allowed
floating point registers to contain SImode or DImode values,
which is sometimes necessary when handling unions.

However, due to the added alternatives for the mov[sd]i insns,
the compiler would sometimes choose to use floating point
registers even if no floating point value or operation was
involved at all.  This is not only usually inefficient, but
in the case of the Linux kernel it is a serious bug:  the
kernel code is not allowed to modify any floating point
register, as they are not saved/restored on kernel<->user
space switches.

To fix this, I've added !* modifiers to the floating point
register constraints of mov[sd]i, preventing the compiler
from choosing them unless the operand is already in a fpr.

Committed to both head and 3.1 branch (as regression fix).

Bootstrapped/regtested on s390-ibm-linux and s390x-ibm-linux,
both head and branch.

Bye,
Ulrich

      * config/s390/s390.md (movsi): Only use floating point
      register alternatives when operands are already fprs.
      (movdi_31, movdi_64): Likewise.


Index: s390.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/s390/s390.md,v
retrieving revision 1.20
diff -c -p -r1.20 s390.md
*** s390.md 29 May 2002 11:59:32 -0000    1.20
--- s390.md 8 Jun 2002 04:15:55 -0000
***************
*** 947,954 ****
     (set_attr "atype"   "mem")])

  (define_insn "*movdi_64"
!   [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,m,f,f,m")
!         (match_operand:DI 1 "general_operand" "d,m,d,f,m,f"))]
    "TARGET_64BIT"
    "@
     lgr\\t%0,%1
--- 947,954 ----
     (set_attr "atype"   "mem")])

  (define_insn "*movdi_64"
!   [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,m,!*f,!*f,!m")
!         (match_operand:DI 1 "general_operand" "d,m,d,*f,m,*f"))]
    "TARGET_64BIT"
    "@
     lgr\\t%0,%1
***************
*** 961,968 ****
     (set_attr "atype"   "reg,mem,mem,reg,mem,mem")])

  (define_insn "*movdi_31"
!   [(set (match_operand:DI 0 "nonimmediate_operand" "=d,Q,d,m,f,f,m")
!         (match_operand:DI 1 "general_operand" "Q,d,dKm,d,f,m,f"))]
    "!TARGET_64BIT"
    "@
     lm\\t%0,%N0,%1
--- 961,968 ----
     (set_attr "atype"   "reg,mem,mem,reg,mem,mem")])

  (define_insn "*movdi_31"
!   [(set (match_operand:DI 0 "nonimmediate_operand" "=d,Q,d,m,!*f,!*f,!m")
!         (match_operand:DI 1 "general_operand" "Q,d,dKm,d,*f,m,*f"))]
    "!TARGET_64BIT"
    "@
     lm\\t%0,%N0,%1
***************
*** 1100,1107 ****
     (set_attr "atype"   "mem")])

  (define_insn "*movsi"
!   [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,m,f,f,m")
!         (match_operand:SI 1 "general_operand" "d,m,d,f,m,f"))]
    ""
    "@
     lr\\t%0,%1
--- 1100,1107 ----
     (set_attr "atype"   "mem")])

  (define_insn "*movsi"
!   [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,m,!*f,!*f,!m")
!         (match_operand:SI 1 "general_operand" "d,m,d,*f,m,*f"))]
    ""
    "@
     lr\\t%0,%1


Mit freundlichen Gruessen / Best Regards

Ulrich Weigand

--
  Dr. Ulrich Weigand
  Linux for S/390 Design & Development
  IBM Deutschland Entwicklung GmbH, Schoenaicher Str. 220, 71032 Boeblingen
  Phone: +49-7031/16-3727   ---   Email: Ulrich.Weigand@de.ibm.com



More information about the Gcc-patches mailing list