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

[Committed] S/390: Invalid slgfi instruction emitted with -march=z9-109


Hello,

the attached patch fixes a problem with the 'On' constraint in the
s390 back end.

I've fixed this problem already last year:
http://gcc.gnu.org/ml/gcc-patches/2006-05/msg00499.html

But accidently the patch has been reverted by:
http://gcc.gnu.org/ml/gcc-patches/2006-10/msg00073.html

So I better try it with a testcase this time ;)

Boostrapped on s390 and s390x with --with-arch=z9-ec.
No testsuite regressions.

Bye,

-Andreas-


2007-12-12  Andreas Krebbel  <krebbel1@de.ibm.com>

	* config/s390/s390.c (s390_O_constraint_str): Limit the range
	for 'On' to -4G+1..-1.
	* config/s390/constraints.md: Adjust comment accordingly.

2007-12-12  Andreas Krebbel  <krebbel1@de.ibm.com>

	* gcc.target/s390/20071212-1.c: New testcase.


Index: gcc/config/s390/s390.c
===================================================================
*** gcc/config/s390/s390.c.orig	2007-12-12 09:40:51.000000000 +0100
--- gcc/config/s390/s390.c	2007-12-12 09:45:40.000000000 +0100
*************** s390_O_constraint_str (const char c, HOS
*** 2056,2063 ****
  	|| s390_single_part (GEN_INT (value), DImode, SImode, 0) == 1;
  
      case 'n':
!       return value == -1
! 	|| s390_single_part (GEN_INT (value), DImode, SImode, -1) == 1;
  
      default:
        gcc_unreachable ();
--- 2056,2062 ----
  	|| s390_single_part (GEN_INT (value), DImode, SImode, 0) == 1;
  
      case 'n':
!       return s390_single_part (GEN_INT (value - 1), DImode, SImode, -1) == 1;
  
      default:
        gcc_unreachable ();
Index: gcc/config/s390/constraints.md
===================================================================
*** gcc/config/s390/constraints.md.orig	2007-12-12 09:40:51.000000000 +0100
--- gcc/config/s390/constraints.md	2007-12-12 09:45:40.000000000 +0100
***************
*** 49,55 ****
  ;;    O -- Multiple letter constraint followed by 1 parameter.
  ;;         s:  Signed extended immediate value (-2G .. 2G-1).
  ;;         p:  Positive extended immediate value (0 .. 4G-1).
! ;;         n:  Negative extended immediate value (-4G .. -1).
  ;;         These constraints do not accept any operand if the machine does
  ;;         not provide the extended-immediate facility.
  ;;    P -- Any integer constant that can be loaded without literal pool.
--- 49,55 ----
  ;;    O -- Multiple letter constraint followed by 1 parameter.
  ;;         s:  Signed extended immediate value (-2G .. 2G-1).
  ;;         p:  Positive extended immediate value (0 .. 4G-1).
! ;;         n:  Negative extended immediate value (-4G+1 .. -1).
  ;;         These constraints do not accept any operand if the machine does
  ;;         not provide the extended-immediate facility.
  ;;    P -- Any integer constant that can be loaded without literal pool.
***************
*** 337,343 ****
  
  (define_constraint "On"
    "@internal
!    Negative extended immediate value (-4G .. -1).
     This constraint will only match if the machine provides
     the extended-immediate facility."
    (and (match_code "const_int")
--- 337,343 ----
  
  (define_constraint "On"
    "@internal
!    Negative extended immediate value (-4G+1 .. -1).
     This constraint will only match if the machine provides
     the extended-immediate facility."
    (and (match_code "const_int")
Index: gcc/testsuite/gcc.target/s390/20071212-1.c
===================================================================
*** /dev/null	1970-01-01 00:00:00.000000000 +0000
--- gcc/testsuite/gcc.target/s390/20071212-1.c	2007-12-12 09:56:28.000000000 +0100
***************
*** 0 ****
--- 1,11 ----
+ /* This used to fail due to bug in the On constraint causing a slgfi
+    to be emitted with an immediate not fitting into 32bit.  */
+ 
+ /* { dg-do compile } */
+ /* { dg-options "-O3 -march=z9-109" } */
+ 
+ long
+ foo (long a)
+ {
+   return a - (1ULL << 32);
+ }


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