[PATCH 12/17] big-shift: simplify over-sized OP_SHLs

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

 



In the mathematical sense, the result of a left-shift by an
amount bigger than the operand size equals zero.

Do the corresponding simplification.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 simplify.c                   | 2 ++
 validation/optim/shift-big.c | 7 +++++++
 2 files changed, 9 insertions(+)

diff --git a/simplify.c b/simplify.c
index 9b700abc8..3b8e22c54 100644
--- a/simplify.c
+++ b/simplify.c
@@ -557,6 +557,8 @@ static int simplify_shift(struct instruction *insn, pseudo_t pseudo, long long v
 		break;
 	case OP_LSR:
 		size = operand_size(insn, pseudo);
+		/* fall through */
+	case OP_SHL:
 		if (value >= size)
 			return replace_with_pseudo(insn, value_pseudo(0));
 	}
diff --git a/validation/optim/shift-big.c b/validation/optim/shift-big.c
index 3249854e2..da65c5cdb 100644
--- a/validation/optim/shift-big.c
+++ b/validation/optim/shift-big.c
@@ -3,6 +3,7 @@ typedef          int s32;
 
 static u32 lsr32(u32 a) { return a >> 32; }
 static s32 asr32(s32 a) { return a >> 32; }
+static u32 shl32(u32 a) { return a << 32; }
 
 /*
  * check-name: optim/shift-big.c
@@ -23,5 +24,11 @@ asr32:
 	ret.32      %r5
 
 
+shl32:
+.L4:
+	<entry-point>
+	ret.32      $0
+
+
  * check-output-end
  */
-- 
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