[PATCH 5/5] simplify ((x >> S) << S)

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

 



The simplification of ((x << S) >> S) was already added
but its dual was forgotten.

Add it now.

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

diff --git a/simplify.c b/simplify.c
index b1ccc510d..de115d6df 100644
--- a/simplify.c
+++ b/simplify.c
@@ -683,6 +683,13 @@ static int simplify_shift(struct instruction *insn, pseudo_t pseudo, long long v
 		if (value >= size)
 			goto zero;
 		switch(DEF_OPCODE(def, pseudo)) {
+		case OP_LSR:
+			// replace ((x >> S) << S)
+			// by      (x & (-1 << S))
+			if (def->src2 != insn->src2)
+				break;
+			mask = bits_mask(insn->size - value) << value;
+			goto replace_mask;
 		case OP_SHL:
 		case_shift_shift:		// also for LSR - LSR
 			if (def == insn)	// cyclic DAG!
diff --git a/validation/optim/shl-lsr0.c b/validation/optim/shl-lsr0.c
index 851f62842..fc2561bd1 100644
--- a/validation/optim/shl-lsr0.c
+++ b/validation/optim/shl-lsr0.c
@@ -6,7 +6,6 @@ unsigned mask(unsigned x)
 /*
  * check-name: shl-lsr0
  * check-command: test-linearize -Wno-decl $file
- * check-known-to-fail
  *
  * check-output-ignore
  * check-output-contains: and\\..*0xffff8000
-- 
2.18.0




[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