This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[committed] S/390: Improve double-word constant loading
- From: Ulrich Weigand <uweigand at de dot ibm dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 15 Aug 2005 01:16:40 +0200 (CEST)
- Subject: [committed] S/390: Improve double-word constant loading
Hello,
this adds a small improvement to the handling of double-word
constants. If the constant is of a form that allows it to be
split into two single-word constants, each of which can be
loaded without literal pool, then so can the double-word
constant.
Bootstrapped/regtested on s390-ibm-linux and s390x-ibm-linux,
committed to mainline.
Bye,
Ulrich
ChangeLog:
* config/s390/s390.c (s390_const_ok_for_constraint_p): Add 'P'
constraint.
(legitimate_reload_constant_p): Fix handling of lliXX operands.
Accept double-word constants that can be split.
* config/s390/s390.md ("movti"): Use 'P' constraint.
("*movdi_31", "*movdf_31"): Likewise.
Index: gcc/config/s390/s390.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/s390/s390.c,v
retrieving revision 1.252
diff -c -p -r1.252 s390.c
*** gcc/config/s390/s390.c 14 Aug 2005 19:06:56 -0000 1.252
--- gcc/config/s390/s390.c 14 Aug 2005 19:21:20 -0000
*************** s390_const_ok_for_constraint_p (HOST_WID
*** 1876,1881 ****
--- 1876,1884 ----
break;
+ case 'P':
+ return legitimate_reload_constant_p (GEN_INT (value));
+
default:
return 0;
}
*************** legitimate_reload_constant_p (rtx op)
*** 2311,2317 ****
/* Accept lliXX operands. */
if (TARGET_ZARCH
! && s390_single_part (op, DImode, HImode, 0) >= 0)
return true;
/* Accept larl operands. */
--- 2314,2322 ----
/* Accept lliXX operands. */
if (TARGET_ZARCH
! && GET_CODE (op) == CONST_INT
! && trunc_int_for_mode (INTVAL (op), word_mode) == INTVAL (op)
! && s390_single_part (op, word_mode, HImode, 0) >= 0)
return true;
/* Accept larl operands. */
*************** legitimate_reload_constant_p (rtx op)
*** 2324,2329 ****
--- 2329,2345 ----
&& CONST_DOUBLE_OK_FOR_CONSTRAINT_P (op, 'G', "G"))
return true;
+ /* Accept double-word operands that can be split. */
+ if (GET_CODE (op) == CONST_INT
+ && trunc_int_for_mode (INTVAL (op), word_mode) != INTVAL (op))
+ {
+ enum machine_mode dword_mode = word_mode == SImode ? DImode : TImode;
+ rtx hi = operand_subword (op, 0, 0, dword_mode);
+ rtx lo = operand_subword (op, 1, 0, dword_mode);
+ return legitimate_reload_constant_p (hi)
+ && legitimate_reload_constant_p (lo);
+ }
+
/* Everything else cannot be handled without reload. */
return false;
}
Index: gcc/config/s390/s390.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/s390/s390.md,v
retrieving revision 1.188
diff -c -p -r1.188 s390.md
*** gcc/config/s390/s390.md 12 Aug 2005 13:49:18 -0000 1.188
--- gcc/config/s390/s390.md 14 Aug 2005 19:21:21 -0000
***************
*** 47,52 ****
--- 47,53 ----
;; has a value different from its other parts. If the letter x
;; is specified instead of a part number, the constraint matches
;; if there is any single part with non-default value.
+ ;; P -- Any integer constant that can be loaded without literal pool.
;; Q -- Memory reference without index register and with short displacement.
;; R -- Memory reference with index register and short displacement.
;; S -- Memory reference without index register but with long displacement.
***************
*** 785,791 ****
(define_insn "movti"
[(set (match_operand:TI 0 "nonimmediate_operand" "=d,QS,d,o,Q")
! (match_operand:TI 1 "general_operand" "QS,d,dKm,d,Q"))]
"TARGET_64BIT"
"@
lmg\t%0,%N0,%S1
--- 786,792 ----
(define_insn "movti"
[(set (match_operand:TI 0 "nonimmediate_operand" "=d,QS,d,o,Q")
! (match_operand:TI 1 "general_operand" "QS,d,dPm,d,Q"))]
"TARGET_64BIT"
"@
lmg\t%0,%N0,%S1
***************
*** 938,944 ****
(define_insn "*movdi_31"
[(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,Q,S,d,o,!*f,!*f,!*f,!R,!T,Q")
! (match_operand:DI 1 "general_operand" "Q,S,d,d,dKm,d,*f,R,T,*f,*f,Q"))]
"!TARGET_64BIT"
"@
lm\t%0,%N0,%S1
--- 939,945 ----
(define_insn "*movdi_31"
[(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,Q,S,d,o,!*f,!*f,!*f,!R,!T,Q")
! (match_operand:DI 1 "general_operand" "Q,S,d,d,dPm,d,*f,R,T,*f,*f,Q"))]
"!TARGET_64BIT"
"@
lm\t%0,%N0,%S1
***************
*** 1400,1406 ****
(define_insn "*movdf_31"
[(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,f,f,R,T,d,d,Q,S,d,o,Q")
! (match_operand:DF 1 "general_operand" "G,f,R,T,f,f,Q,S,d,d,dKm,d,Q"))]
"!TARGET_64BIT"
"@
lzdr\t%0
--- 1401,1407 ----
(define_insn "*movdf_31"
[(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,f,f,R,T,d,d,Q,S,d,o,Q")
! (match_operand:DF 1 "general_operand" "G,f,R,T,f,f,Q,S,d,d,dPm,d,Q"))]
"!TARGET_64BIT"
"@
lzdr\t%0
--
Dr. Ulrich Weigand
Linux on zSeries Development
Ulrich.Weigand@de.ibm.com