From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: Dibyendu Majumdar <mobile@majumdar.org.uk>
Cc: linux-sparse@vger.kernel.org,
Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 1/3] new helper: def_opcode()
Date: Mon, 7 Aug 2017 03:33:36 +0200 [thread overview]
Message-ID: <20170807013338.46211-2-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20170807013338.46211-1-luc.vanoostenryck@gmail.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
simplify.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/simplify.c b/simplify.c
index f292fd5b6..cfb6b2cda 100644
--- a/simplify.c
+++ b/simplify.c
@@ -380,6 +380,13 @@ static int replace_with_pseudo(struct instruction *insn, pseudo_t pseudo)
return REPEAT_CSE;
}
+static inline int def_opcode(pseudo_t p)
+{
+ if (p->type != PSEUDO_REG)
+ return -1;
+ return p->def->opcode;
+}
+
static unsigned int value_size(long long value)
{
value >>= 8;
@@ -404,9 +411,9 @@ static unsigned int operand_size(struct instruction *insn, pseudo_t pseudo)
{
unsigned int size = insn->size;
- if (pseudo->type == PSEUDO_REG) {
+ if (def_opcode(pseudo) == OP_CAST) {
struct instruction *src = pseudo->def;
- if (src && src->opcode == OP_CAST && src->orig_type) {
+ if (src->orig_type) {
unsigned int orig_size = src->orig_type->bit_size;
if (orig_size < size)
size = orig_size;
@@ -822,13 +829,11 @@ static int simplify_associative_binop(struct instruction *insn)
if (!simple_pseudo(insn->src2))
return 0;
- if (pseudo->type != PSEUDO_REG)
+ if (def_opcode(pseudo) != insn->opcode)
return 0;
def = pseudo->def;
if (def == insn)
return 0;
- if (def->opcode != insn->opcode)
- return 0;
if (!simple_pseudo(def->src2))
return 0;
if (ptr_list_size((struct ptr_list *)def->target->users) != 1)
@@ -993,9 +998,9 @@ static int simplify_cast(struct instruction *insn)
}
/* A cast of a "and" might be a no-op.. */
- if (src->type == PSEUDO_REG) {
+ if (def_opcode(src) == OP_AND) {
struct instruction *def = src->def;
- if (def->opcode == OP_AND && def->size >= size) {
+ if (def->size >= size) {
pseudo_t val = def->src2;
if (val->type == PSEUDO_VAL) {
unsigned long long value = val->value;
--
2.13.2
next prev parent reply other threads:[~2017-08-07 1:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-07 1:33 [PATCH 0/3] fix loading of partially defined bitfield Luc Van Oostenryck
2017-08-07 1:33 ` Luc Van Oostenryck [this message]
2017-08-07 1:33 ` [PATCH 2/3] change loading of bitfields Luc Van Oostenryck
2017-08-07 1:33 ` [PATCH 3/3] simplify ((A & M') | B ) & M when M' & M == 0 Luc Van Oostenryck
2017-08-07 1:59 ` [PATCH 0/3] fix loading of partially defined bitfield Christopher Li
2017-08-07 2:00 ` Christopher Li
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=20170807013338.46211-2-luc.vanoostenryck@gmail.com \
--to=luc.vanoostenryck@gmail.com \
--cc=linux-sparse@vger.kernel.org \
--cc=mobile@majumdar.org.uk \
/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 NNTP newsgroup(s).