[PATCH 15/17] fix cost of dereference of symbols with complex type

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

 



Currently, in expand_dereference(), the dereference of a symbol with
a complex type is considered as costing as high as a non-symbol
because it's not recognised it's a symbol.

However, both cases should have exactly the same cost since they
address calculation amounts to 'symbol + offset'.

So, instead of taking in account a single level of
	symbol + offset
let's use a loop for this in order to handle
	symbol [+ offset]*

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 expand.c                              | 10 +++++-----
 validation/expand/cost-deref-nested.c |  1 -
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/expand.c b/expand.c
index cd348bf5833e..36612c8672dd 100644
--- a/expand.c
+++ b/expand.c
@@ -737,12 +737,12 @@ static int expand_dereference(struct expression *expr)
 	 * Is it "symbol" or "symbol + offset"?
 	 */
 	offset = 0;
-	if (unop->type == EXPR_BINOP && unop->op == '+') {
+	while (unop->type == EXPR_BINOP && unop->op == '+') {
 		struct expression *right = unop->right;
-		if (right->type == EXPR_VALUE) {
-			offset = right->value;
-			unop = unop->left;
-		}
+		if (right->type != EXPR_VALUE)
+			break;
+		offset += right->value;
+		unop = unop->left;
 	}
 
 	if (unop->type == EXPR_SYMBOL) {
diff --git a/validation/expand/cost-deref-nested.c b/validation/expand/cost-deref-nested.c
index b09602b6acc6..d6b623961378 100644
--- a/validation/expand/cost-deref-nested.c
+++ b/validation/expand/cost-deref-nested.c
@@ -14,7 +14,6 @@ static int foo(int c)
 /*
  * check-name: cost-deref-nested
  * check-command: test-linearize -fdump-ir $file
- * check-known-to-fail
  *
  * check-output-ignore
  * check-output-excludes: cbr
-- 
2.24.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