public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <jeffreyalaw@gmail.com>
To: Jan-Benedict Glaw <jbglaw@lug-owl.de>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [committed] More infrastructure to avoid bogus RTL on H8
Date: Fri, 28 Oct 2022 21:35:48 -0600	[thread overview]
Message-ID: <025493a0-2924-a05c-7d1f-3bbe8c24b5dc@gmail.com> (raw)
In-Reply-To: <20221025195906.rk5wx6ttpwohwn4p@lug-owl.de>

[-- Attachment #1: Type: text/plain, Size: 1501 bytes --]


On 10/25/22 13:59, Jan-Benedict Glaw wrote:
> Hi Jeff!
>
> On Mon, 2022-10-17 17:47:16 -0600, Jeff Law via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
>> --- a/gcc/config/h8300/h8300.cc
>> +++ b/gcc/config/h8300/h8300.cc
>> @@ -5531,6 +5531,32 @@ h8300_ok_for_sibcall_p (tree fndecl, tree)
>>   
>>     return 1;
>>   }
>> +
>> +/* Return TRUE if OP is a PRE_INC or PRE_DEC
>> +   instruction using REG, FALSE otherwise.  */
>> +
>> +bool
>> +pre_incdec_with_reg (rtx op, int reg)
>> +{
>> +  /* OP must be a MEM.  */
>> +  if (GET_CODE (op) != MEM)
>> +    return false;
>> +
>> +  /* The address must be a PRE_INC or PRE_DEC.  */
>> +  op = XEXP (op, 0);
>> +  if (GET_CODE (op) != PRE_DEC && GET_CODE (op) != PRE_INC)
>> +    return false;
>> +
>> +  /* It must be a register that is being incremented
>> +     or decremented.  */
>> +  op = XEXP (op, 0);
>> +  if (!REG_P (op))
>> +    return false;
>> +
>> +  /* Finally, check that the register number matches.  */
>> +  return REGNO (op) == reg;
> This results in a new signed-vs-unsigned warning for me:
>
> [all 2022-10-25 00:41:11] ../../gcc/gcc/config/h8300/h8300.cc: In function 'bool pre_incdec_with_reg(rtx, int)':
> [all 2022-10-25 00:41:11] ../../gcc/gcc/config/h8300/h8300.cc:5557:21: error: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Werror=sign-compare]
> [all 2022-10-25 00:41:11]  5557 |   return REGNO (op) == reg;

Fixed via the attached patch.  Thanks for pointing it out.


jeff


[-- Attachment #2: P --]
[-- Type: text/plain, Size: 1414 bytes --]

commit 724d3f926b94672de960dbe88fb699bbdd7fde97
Author: Jeff Law <jeffreyalaw@gmail.com>
Date:   Fri Oct 28 23:33:06 2022 -0400

    Fix signed vs unsigned issue in H8 port
    
    gcc/
            * config/h8300/h8300.cc (pre_incdec_with_reg): Make reg argument
            an unsigned int
            * config/h8300/h8300-protos.h (pre_incdec_with_reg): Adjust prototype.

diff --git a/gcc/config/h8300/h8300-protos.h b/gcc/config/h8300/h8300-protos.h
index 8c989495c29..77adfaba07b 100644
--- a/gcc/config/h8300/h8300-protos.h
+++ b/gcc/config/h8300/h8300-protos.h
@@ -100,7 +100,7 @@ extern int h8300_initial_elimination_offset (int, int);
 extern int h8300_regs_ok_for_stm (int, rtx[]);
 extern int h8300_hard_regno_rename_ok (unsigned int, unsigned int);
 extern bool h8300_move_ok (rtx, rtx);
-extern bool pre_incdec_with_reg (rtx, int);
+extern bool pre_incdec_with_reg (rtx, unsigned int);
 
 struct cpp_reader;
 extern void h8300_pr_interrupt (struct cpp_reader *);
diff --git a/gcc/config/h8300/h8300.cc b/gcc/config/h8300/h8300.cc
index ce0702edecb..cd7975e2fff 100644
--- a/gcc/config/h8300/h8300.cc
+++ b/gcc/config/h8300/h8300.cc
@@ -5536,7 +5536,7 @@ h8300_ok_for_sibcall_p (tree fndecl, tree)
    instruction using REG, FALSE otherwise.  */
 
 bool
-pre_incdec_with_reg (rtx op, int reg)
+pre_incdec_with_reg (rtx op, unsigned int reg)
 {
   /* OP must be a MEM.  */
   if (GET_CODE (op) != MEM)

      reply	other threads:[~2022-10-29  3:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-17 23:47 Jeff Law
2022-10-25 19:59 ` Jan-Benedict Glaw
2022-10-29  3:35   ` Jeff Law [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=025493a0-2924-a05c-7d1f-3bbe8c24b5dc@gmail.com \
    --to=jeffreyalaw@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jbglaw@lug-owl.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).