@@ -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;
}
@@ -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
@@ -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
@@ -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
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> --- simplify.c | 3 +++ validation/linear/pointer-arith32.c | 12 ++++++------ validation/linear/pointer-arith64.c | 10 +++++----- validation/optim/cse-arg01.c | 1 - 4 files changed, 14 insertions(+), 12 deletions(-)