This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Warning patrol: reload.c, reload1.c
- To: gcc-patches at gcc dot gnu dot org
- Subject: [patch] Warning patrol: reload.c, reload1.c
- From: Jan van Male <jan dot vanmale at fenk dot wau dot nl>
- Date: Sun, 24 Jun 2001 18:27:02 +0200
- Reply-To: jan dot vanmale at fenk dot wau dot nl
Hi,
This patch eliminates the following bootstrap warnings:
../../gcc/gcc/reload.c: In function `push_reload':
../../gcc/gcc/reload.c:1050: warning: passing arg 4 of `push_reload' from incompatible pointer type
../../gcc/gcc/reload.c: In function `regno_clobbered_p':
../../gcc/gcc/reload.c:6718: warning: comparison between signed and unsigned
../../gcc/gcc/reload.c:6734: warning: comparison between signed and unsigned
../../gcc/gcc/reload1.c: In function `replace_pseudos_in_call_usage':
../../gcc/gcc/reload1.c:624: warning: comparison between signed and unsigned
../../gcc/gcc/reload1.c: In function `reload_combine':
../../gcc/gcc/reload1.c:8837: warning: comparison between signed and unsigned
../../gcc/gcc/reload1.c:8599: warning: `last_index_reg' might be used uninitialized in this function
The fix to the first warning is trivial. The rest as well probably if
you're familiar with the compiler.
For the 2nd and 3rd I've convinced myself that
REGNO always returns an unsigned int.
HARD_REGNO_NREGS should as well given this comment
/* Return number of consecutive hard regs needed starting at reg REGNO
to hold something of mode MODE.
This is ordinarily the length in words of a value of mode MODE
but can be less for certain modes in special long registers.
Actually there are no two word move instructions for consecutive
registers. And only registers 0-3 may have mov byte instructions
applied to them.
*/
This macro is redefined for different targets, I didn't bother to check them all.
But I'd be surprised to find out that this macro ever returns a negative
value.
The 4rd warning fix is trivial, since REGNO returns an unsigned int.
The fifth warning fix is trivial once you realise that `i' is used as a
positive loop counter.
The last warning is a false positive warning with a trivial work-around.
Bootstrapped and tested (only for c,c++,f77,objc) without regressions on
i686-pc-linux-gnu. Please apply the patch if it is ok.
jan
Changelog:
2001-06-24 Jan van Male <jan.vanmale@fenk.wau.nl>
* reload.c (push_reload): Fix warning.
(regno_clobbered_p): Likewise.
* reload1.c (replace_pseudos_in_call_usage): Likewise.
(reload_combine): Likewise.
Index: gcc/gcc/reload.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reload.c,v
retrieving revision 1.147
diff -c -3 -p -r1.147 reload.c
*** reload.c 2001/06/04 01:58:24 1.147
--- reload.c 2001/06/24 15:34:47
*************** push_reload (in, out, inloc, outloc, cla
*** 1046,1052 ****
order as the reloads. Thus if the outer reload is also of type
RELOAD_OTHER, we are guaranteed that this inner reload will be
output before the outer reload. */
! push_reload (SUBREG_REG (in), NULL_RTX, &SUBREG_REG (in), NULL_RTX,
in_class, VOIDmode, VOIDmode, 0, 0, opnum, type);
dont_remove_subreg = 1;
}
--- 1046,1052 ----
order as the reloads. Thus if the outer reload is also of type
RELOAD_OTHER, we are guaranteed that this inner reload will be
output before the outer reload. */
! push_reload (SUBREG_REG (in), NULL_RTX, &SUBREG_REG (in), (rtx*)0,
in_class, VOIDmode, VOIDmode, 0, 0, opnum, type);
dont_remove_subreg = 1;
}
*************** regno_clobbered_p (regno, insn, mode, se
*** 6706,6719 ****
enum machine_mode mode;
int sets;
{
! int nregs = HARD_REGNO_NREGS (regno, mode);
! int endregno = regno + nregs;
if ((GET_CODE (PATTERN (insn)) == CLOBBER
|| (sets && GET_CODE (PATTERN (insn)) == SET))
&& GET_CODE (XEXP (PATTERN (insn), 0)) == REG)
{
! int test = REGNO (XEXP (PATTERN (insn), 0));
return test >= regno && test < endregno;
}
--- 6706,6719 ----
enum machine_mode mode;
int sets;
{
! unsigned int nregs = HARD_REGNO_NREGS (regno, mode);
! unsigned int endregno = regno + nregs;
if ((GET_CODE (PATTERN (insn)) == CLOBBER
|| (sets && GET_CODE (PATTERN (insn)) == SET))
&& GET_CODE (XEXP (PATTERN (insn), 0)) == REG)
{
! unsigned int test = REGNO (XEXP (PATTERN (insn), 0));
return test >= regno && test < endregno;
}
*************** regno_clobbered_p (regno, insn, mode, se
*** 6729,6735 ****
|| (sets && GET_CODE (PATTERN (insn)) == SET))
&& GET_CODE (XEXP (elt, 0)) == REG)
{
! int test = REGNO (XEXP (elt, 0));
if (test >= regno && test < endregno)
return 1;
--- 6729,6735 ----
|| (sets && GET_CODE (PATTERN (insn)) == SET))
&& GET_CODE (XEXP (elt, 0)) == REG)
{
! unsigned int test = REGNO (XEXP (elt, 0));
if (test >= regno && test < endregno)
return 1;
Index: gcc/gcc/reload1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reload1.c,v
retrieving revision 1.271
diff -c -3 -p -r1.271 reload1.c
*** reload1.c 2001/06/22 17:18:20 1.271
--- reload1.c 2001/06/24 15:34:49
*************** replace_pseudos_in_call_usage (loc, mem_
*** 601,607 ****
code = GET_CODE (x);
if (code == REG)
{
! int regno = REGNO (x);
if (regno < FIRST_PSEUDO_REGISTER)
return;
--- 601,607 ----
code = GET_CODE (x);
if (code == REG)
{
! unsigned int regno = REGNO (x);
if (regno < FIRST_PSEUDO_REGISTER)
return;
*************** static void
*** 8596,8602 ****
reload_combine ()
{
rtx insn, set;
! int first_index_reg = -1, last_index_reg;
int i;
unsigned int r;
int last_label_ruid;
--- 8596,8603 ----
reload_combine ()
{
rtx insn, set;
! int first_index_reg = -1;
! int last_index_reg = 0;
int i;
unsigned int r;
int last_label_ruid;
*************** reload_combine ()
*** 8827,8833 ****
rtx usage_rtx = XEXP (XEXP (link, 0), 0);
if (GET_CODE (usage_rtx) == REG)
{
! int i;
unsigned int start_reg = REGNO (usage_rtx);
unsigned int num_regs =
HARD_REGNO_NREGS (start_reg, GET_MODE (usage_rtx));
--- 8828,8834 ----
rtx usage_rtx = XEXP (XEXP (link, 0), 0);
if (GET_CODE (usage_rtx) == REG)
{
! unsigned int i;
unsigned int start_reg = REGNO (usage_rtx);
unsigned int num_regs =
HARD_REGNO_NREGS (start_reg, GET_MODE (usage_rtx));