[PATCH 09/16] cast: use a switch to handle TRUNC(AND(x,M),N) in simplify_cast()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is in preparation to handle the other casts: ZEXT & SEXT.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 simplify.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/simplify.c b/simplify.c
index 94acd5670..0982d9d4b 100644
--- a/simplify.c
+++ b/simplify.c
@@ -972,8 +972,10 @@ static int simplify_memop(struct instruction *insn)
 
 static int simplify_cast(struct instruction *insn)
 {
+	unsigned long long mask;
 	struct instruction *def;
 	pseudo_t src;
+	pseudo_t val;
 	int osize;
 	int size;
 
@@ -991,14 +993,16 @@ static int simplify_cast(struct instruction *insn)
 	def = src->def;
 	switch (def_opcode(src)) {
 	case OP_AND:
+		val = def->src2;
+		if (val->type != PSEUDO_VAL)
+			break;
 		/* A cast of a AND might be a no-op.. */
-		if (insn->opcode == OP_TRUNC) {
-			pseudo_t val = def->src2;
-			if (val->type == PSEUDO_VAL) {
-				unsigned long long value = val->value;
-				if (!(value >> (size-1)))
-					goto simplify;
-			}
+		switch (insn->opcode) {
+		case OP_TRUNC:
+			mask = val->value;
+			if (!(mask >> (size-1)))
+				goto simplify;
+			break;
 		}
 		break;
 	case OP_TRUNC:
-- 
2.18.0

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux