public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Stefan Schulze Frielinghaus <stefansf@linux.ibm.com>
To: gcc-patches@gcc.gnu.org
Cc: Stefan Schulze Frielinghaus <stefansf@linux.ibm.com>
Subject: [PATCH 1/2] cselib: Keep track of further subvalue relations
Date: Wed,  7 Sep 2022 16:20:25 +0200	[thread overview]
Message-ID: <20220907142026.936922-2-stefansf@linux.ibm.com> (raw)
In-Reply-To: <20220907142026.936922-1-stefansf@linux.ibm.com>

Whenever a new cselib value is created check whether a smaller value
exists which is contained in the bigger one.  If so add a subreg
relation to locs of the smaller one.

gcc/ChangeLog:

	* cselib.cc (new_cselib_val): Keep track of further subvalue
	relations.
---
 gcc/cselib.cc | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/gcc/cselib.cc b/gcc/cselib.cc
index 6a5609786fa..9b582e5d3d6 100644
--- a/gcc/cselib.cc
+++ b/gcc/cselib.cc
@@ -1569,6 +1569,26 @@ new_cselib_val (unsigned int hash, machine_mode mode, rtx x)
   e->locs = 0;
   e->next_containing_mem = 0;
 
+  scalar_int_mode int_mode;
+  if (REG_P (x) && is_int_mode (mode, &int_mode)
+      && REG_VALUES (REGNO (x)) != NULL
+      && (!cselib_current_insn || !DEBUG_INSN_P (cselib_current_insn)))
+    {
+      rtx copy = shallow_copy_rtx (x);
+      scalar_int_mode narrow_mode_iter;
+      FOR_EACH_MODE_UNTIL (narrow_mode_iter, int_mode)
+	{
+	  PUT_MODE_RAW (copy, narrow_mode_iter);
+	  cselib_val *v = cselib_lookup (copy, narrow_mode_iter, 0, VOIDmode);
+	  if (v)
+	    {
+	      rtx sub = lowpart_subreg (narrow_mode_iter, e->val_rtx, int_mode);
+	      if (sub)
+		new_elt_loc_list (v, sub);
+	    }
+	}
+    }
+
   if (dump_file && (dump_flags & TDF_CSELIB))
     {
       fprintf (dump_file, "cselib value %u:%u ", e->uid, hash);
-- 
2.37.2


  reply	other threads:[~2022-09-07 14:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-07 14:20 [PATCH 0/2] Variable tracking and subvalues Stefan Schulze Frielinghaus
2022-09-07 14:20 ` Stefan Schulze Frielinghaus [this message]
2022-09-26  6:10   ` [PATCH 1/2] cselib: Keep track of further subvalue relations Stefan Schulze Frielinghaus
2022-09-27 23:46   ` Jeff Law
2022-09-29 17:40     ` Joseph Myers
2022-09-07 14:20 ` [PATCH 2/2] var-tracking: Add entry values up to max register mode Stefan Schulze Frielinghaus
2022-09-26  6:10   ` Stefan Schulze Frielinghaus
2022-09-27 23:44   ` Jeff Law

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=20220907142026.936922-2-stefansf@linux.ibm.com \
    --to=stefansf@linux.ibm.com \
    --cc=gcc-patches@gcc.gnu.org \
    /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).