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:17 +0100
commitef00ea2fa5203a2e3da3e3c7f2c46668d66c31c9 (patch)
treea036348247ee6c92408dfc5373f36e588eb8a7c3
parenta1c7b6f159cfd5137676c6730b3d14ddd411dc57 (diff)
downloadsparse-ef00ea2fa5203a2e3da3e3c7f2c46668d66c31c9.tar.gz
canon: put PSEUDO_REGs in canonical order too
Currently, only binops containing PSEUDO_VAL, SYM or ARG were put in canonical order. This means that binops containing only 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, take PSEUDO_REGs 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/optim/cse-reg01.c1
2 files changed, 3 insertions, 1 deletions
diff --git a/simplify.c b/simplify.c
index c809b832..ee485798 100644
--- a/simplify.c
+++ b/simplify.c
@@ -1474,6 +1474,9 @@ static int canonical_order(pseudo_t p1, pseudo_t p2)
if (p1->type == PSEUDO_ARG)
return (p2->type == PSEUDO_ARG && p1->nr <= p2->nr) || p2->type == PSEUDO_VAL || p2->type == PSEUDO_SYM;
+ if (p1->type == PSEUDO_REG)
+ return (p2->type == PSEUDO_REG && p1->nr <= p2->nr) || p2->type == PSEUDO_VAL || p2->type == PSEUDO_SYM || p2->type == PSEUDO_ARG;
+
return 1;
}
diff --git a/validation/optim/cse-reg01.c b/validation/optim/cse-reg01.c
index 938858f4..3ea283d3 100644
--- a/validation/optim/cse-reg01.c
+++ b/validation/optim/cse-reg01.c
@@ -3,7 +3,6 @@ int foo(int a, int b) { int x = a + b, y = ~b; return (x < y) == (y > x); }
/*
* check-name: cse-reg01
* check-command: test-linearize -Wno-decl $file
- * check-known-to-fail
*
* check-output-ignore
* check-output-returns: 1