[PATCH 07/22] constants must be truncated to the operation's size

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

 



At expansion phase, when simplified, all constants are truncated
to the size of the operations that generate them.

This should be done during simplification too because:
*) if some constants are sometimes truncated and sometimes
   sign-extended, CSE will miss some opportunities.
*) it's not possible to sign-extend them because it's not
   always known if the constant is used in a signed context or not.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 simplify.c                           | 2 +-
 validation/optim/canonical-sub-cte.c | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/simplify.c b/simplify.c
index db7a1e47ff0a..3935552bd6fa 100644
--- a/simplify.c
+++ b/simplify.c
@@ -1118,7 +1118,7 @@ static int simplify_constant_rightside(struct instruction *insn)
 	case OP_SUB:
 		if (value) {
 			insn->opcode = OP_ADD;
-			insn->src2 = value_pseudo(-value);
+			insn->src2 = eval_unop(OP_NEG, insn->size, insn->src2);
 			return REPEAT_CSE;
 		}
 	/* Fall through */
diff --git a/validation/optim/canonical-sub-cte.c b/validation/optim/canonical-sub-cte.c
index 223be96fa5a5..c0072884b1e6 100644
--- a/validation/optim/canonical-sub-cte.c
+++ b/validation/optim/canonical-sub-cte.c
@@ -3,7 +3,6 @@ int sub_cte(int x) { return (x - 1) != (x + -1); }
 /*
  * check-name: canonical-sub-cte
  * check-command: test-linearize -Wno-decl $file
- * check-known-to-fail
  *
  * check-output-ignore
  * check-output-contains: ret\\..*\\$0
-- 
2.28.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