aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-11-06 21:22:56 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-11-22 15:30:16 +0100
commita1c7b6f159cfd5137676c6730b3d14ddd411dc57 (patch)
treed4729ea0b123b437129d9fa1b2a82270be035f50
parenteda5c718f55ac471d456752ff7138f1249289dc7 (diff)
downloadsparse-a1c7b6f159cfd5137676c6730b3d14ddd411dc57.tar.gz
canon: put PSEUDO_ARGs in canonical order too
Currently, only binops containing PSEUDO_VAL or PSEUDO_SYM were put in canonical order. This means that binops containing only PSEUDO_ARGs or PSEUDO_REGs are not ordered. This is not directly a problem for CSE because commutativity is taken in account but: * more combination need to be checked during simplification * 'anti-commutative' operations like (a > b) & (b < a) are not recognized as such. So, as a first step, also take PSEUDO_ARGs in account when checking if operands are in canonical order. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--simplify.c3
-rw-r--r--validation/linear/pointer-arith32.c12
-rw-r--r--validation/linear/pointer-arith64.c10
-rw-r--r--validation/optim/cse-arg01.c1
4 files changed, 14 insertions, 12 deletions
diff --git a/simplify.c b/simplify.c
index a0e23d6d..c809b832 100644
--- a/simplify.c
+++ b/simplify.c
@@ -1471,6 +1471,9 @@ static int canonical_order(pseudo_t p1, pseudo_t p2)
if (p1->type == PSEUDO_SYM)
return p2->type == PSEUDO_SYM || p2->type == PSEUDO_VAL;
+ if (p1->type == PSEUDO_ARG)
+ return (p2->type == PSEUDO_ARG && p1->nr <= p2->nr) || p2->type == PSEUDO_VAL || p2->type == PSEUDO_SYM;
+
return 1;
}
diff --git a/validation/linear/pointer-arith32.c b/validation/linear/pointer-arith32.c
index 531fd232..c0163a6f 100644
--- a/validation/linear/pointer-arith32.c
+++ b/validation/linear/pointer-arith32.c
@@ -42,7 +42,7 @@ cps:
.L0:
<entry-point>
sext.32 %r2 <- (16) %arg2
- add.32 %r5 <- %arg1, %r2
+ add.32 %r5 <- %r2, %arg1
ret.32 %r5
@@ -51,7 +51,7 @@ ipss:
<entry-point>
sext.32 %r10 <- (16) %arg2
mul.32 %r11 <- %r10, $4
- add.32 %r14 <- %arg1, %r11
+ add.32 %r14 <- %r11, %arg1
ret.32 %r14
@@ -60,7 +60,7 @@ ipus:
<entry-point>
zext.32 %r19 <- (16) %arg2
mul.32 %r20 <- %r19, $4
- add.32 %r23 <- %arg1, %r20
+ add.32 %r23 <- %r20, %arg1
ret.32 %r23
@@ -68,7 +68,7 @@ cpq:
.L6:
<entry-point>
trunc.32 %r28 <- (64) %arg2
- add.32 %r31 <- %arg1, %r28
+ add.32 %r31 <- %r28, %arg1
ret.32 %r31
@@ -77,7 +77,7 @@ ipq_ref:
<entry-point>
trunc.32 %r37 <- (64) %arg2
mul.32 %r38 <- %r37, $4
- add.32 %r39 <- %arg1, %r38
+ add.32 %r39 <- %r38, %arg1
ret.32 %r39
@@ -86,7 +86,7 @@ ipq:
<entry-point>
trunc.32 %r43 <- (64) %arg2
mul.32 %r44 <- %r43, $4
- add.32 %r47 <- %arg1, %r44
+ add.32 %r47 <- %r44, %arg1
ret.32 %r47
diff --git a/validation/linear/pointer-arith64.c b/validation/linear/pointer-arith64.c
index dad10331..7f1aac56 100644
--- a/validation/linear/pointer-arith64.c
+++ b/validation/linear/pointer-arith64.c
@@ -35,7 +35,7 @@ cps:
.L0:
<entry-point>
sext.64 %r2 <- (16) %arg2
- add.64 %r5 <- %arg1, %r2
+ add.64 %r5 <- %r2, %arg1
ret.64 %r5
@@ -44,7 +44,7 @@ ipss:
<entry-point>
sext.64 %r10 <- (16) %arg2
mul.64 %r11 <- %r10, $4
- add.64 %r14 <- %arg1, %r11
+ add.64 %r14 <- %r11, %arg1
ret.64 %r14
@@ -53,7 +53,7 @@ ipus:
<entry-point>
zext.64 %r19 <- (16) %arg2
mul.64 %r20 <- %r19, $4
- add.64 %r23 <- %arg1, %r20
+ add.64 %r23 <- %r20, %arg1
ret.64 %r23
@@ -62,7 +62,7 @@ ipsi:
<entry-point>
sext.64 %r28 <- (32) %arg2
mul.64 %r29 <- %r28, $4
- add.64 %r32 <- %arg1, %r29
+ add.64 %r32 <- %r29, %arg1
ret.64 %r32
@@ -71,7 +71,7 @@ ipui:
<entry-point>
zext.64 %r37 <- (32) %arg2
mul.64 %r38 <- %r37, $4
- add.64 %r41 <- %arg1, %r38
+ add.64 %r41 <- %r38, %arg1
ret.64 %r41
diff --git a/validation/optim/cse-arg01.c b/validation/optim/cse-arg01.c
index c3f2963f..3e3e141a 100644
--- a/validation/optim/cse-arg01.c
+++ b/validation/optim/cse-arg01.c
@@ -3,7 +3,6 @@ int foo(int a, int b) { return (a < b) == (b > a); }
/*
* check-name: cse-arg01
* check-command: test-linearize -Wno-decl $file
- * check-known-to-fail
*
* check-output-ignore
* check-output-returns: 1