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]

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


Hello,

compiling with -march=z9-109 gcc emits an invalid subtraction instruction with
a value of 4G as immediate. In cases like x + c we allow -4G through -1 for c
when emitting a slgfi instruction and negate the value of c in the assembler code.
For x + (-4G) we therefore emit a subract instruction with 4G as immediate which
does not fit into 32bit. The attached patch limits the On constraint to 
-4G+1 through -1 fixing the problem.

Ulrich approved it offline. Committed to mainline and 4.1 branch.

GCC 4.1 bootstrapped on s390x with --with-arch=z9-109.
No testsuite regressions.

Bye,

-Andreas-


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

	* config/s390/s390.c (s390_const_ok_for_constraint_p): Disallow -4G for
	On contraint.
	* config/s390/s390.md: Adjust comment describing On constraint.


Index: gcc/config/s390/s390.c
===================================================================
*** gcc/config/s390/s390.c.orig	2006-04-18 09:37:46.000000000 +0200
--- gcc/config/s390/s390.c	2006-05-11 15:09:04.000000000 +0200
*************** s390_const_ok_for_constraint_p (HOST_WID
*** 2075,2082 ****
  	    || 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 ();
--- 2075,2084 ----
  	    || 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)
! 	    && value != -((HOST_WIDE_INT)1 << 32);
  	  
  	default:
  	  gcc_unreachable ();
Index: gcc/config/s390/s390.md
===================================================================
*** gcc/config/s390/s390.md.orig	2006-04-24 10:51:06.000000000 +0200
--- gcc/config/s390/s390.md	2006-05-11 15:06:46.000000000 +0200
***************
*** 50,56 ****
  ;;    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.
--- 50,56 ----
  ;;    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.


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