All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 5/6] memops: avoid using first_pseudo()
Date: Sun, 21 Mar 2021 18:08:21 +0100	[thread overview]
Message-ID: <20210321170822.46854-6-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20210321170822.46854-1-luc.vanoostenryck@gmail.com>

The loop in rewrite_load_instruction() uses first_pseudo() to not have
to special case the first element.

But this slightly complicates further changes.

So, simply use a null-or-no-null test inside the loop to identify
this first element.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 memops.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/memops.c b/memops.c
index 119a39a180d5..897fb6bf57fe 100644
--- a/memops.c
+++ b/memops.c
@@ -19,15 +19,17 @@
 
 static void rewrite_load_instruction(struct instruction *insn, struct pseudo_list *dominators)
 {
-	pseudo_t new, phi;
+	pseudo_t new = NULL;
+	pseudo_t phi;
 
 	/*
 	 * Check for somewhat common case of duplicate
 	 * phi nodes.
 	 */
-	new = first_pseudo(dominators)->def->phi_src;
 	FOR_EACH_PTR(dominators, phi) {
-		if (new != phi->def->phi_src)
+		if (!new)
+			new = phi->def->phi_src;
+		else if (new != phi->def->phi_src)
 			goto complex_phi;
 	} END_FOR_EACH_PTR(phi);
 
-- 
2.31.0


  parent reply	other threads:[~2021-03-21 17:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-21 17:08 [PATCH 0/6] memops: small cleanups Luc Van Oostenryck
2021-03-21 17:08 ` [PATCH 1/6] memops: dominates()s first arg is redundant Luc Van Oostenryck
2021-03-21 17:08 ` [PATCH 2/6] memops: find_dominating_parents()s generation " Luc Van Oostenryck
2021-03-21 17:08 ` [PATCH 3/6] memops: remove obsolete comment Luc Van Oostenryck
2021-03-21 17:08 ` [PATCH 4/6] memops: do not mess up with phisource's source ident Luc Van Oostenryck
2021-03-21 17:08 ` Luc Van Oostenryck [this message]
2021-03-21 17:08 ` [PATCH 6/6] memops: we can kill addresses unconditionally Luc Van Oostenryck

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=20210321170822.46854-6-luc.vanoostenryck@gmail.com \
    --to=luc.vanoostenryck@gmail.com \
    --cc=linux-sparse@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.