aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-07-31 00:24:17 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-08-06 08:50:52 +0200
commit34c4c964d0969a5c594b6bedaa3d749cf1ba6e24 (patch)
tree00e978f31a08cecdf418eb85339f1ea2c83c77da
parent5fccf5f5a85d01ca21d06675216345a182555cce (diff)
downloadsparse-dev-34c4c964d0969a5c594b6bedaa3d749cf1ba6e24.tar.gz
simplify SETNE(AND(X,1),0) to AND(X,1)
Since the OP_SETCC instructions can only return a 0 or a 1, a compare-not-equal-zero or compare-equal-1 is a no-op if the operand have been masked with 1. Remove the no-op comparison (if the size matches). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--simplify.c10
-rw-r--r--validation/optim/mask1-setne0.c1
2 files changed, 10 insertions, 1 deletions
diff --git a/simplify.c b/simplify.c
index 839452b0..ae53e7ae 100644
--- a/simplify.c
+++ b/simplify.c
@@ -713,6 +713,16 @@ static int simplify_seteq_setne(struct instruction *insn, long long value)
}
opcode = def->opcode;
switch (opcode) {
+ case OP_AND:
+ if (inverse)
+ break;
+ if (def->size != insn->size)
+ break;
+ if (def->src2->type != PSEUDO_VAL)
+ break;
+ if (def->src2->value != 1)
+ break;
+ return replace_with_pseudo(insn, old);
case OP_FPCMP ... OP_BINCMP_END:
// Convert:
// setcc.n %t <- %a, %b
diff --git a/validation/optim/mask1-setne0.c b/validation/optim/mask1-setne0.c
index 8810189c..1e599dc8 100644
--- a/validation/optim/mask1-setne0.c
+++ b/validation/optim/mask1-setne0.c
@@ -16,7 +16,6 @@ int foo(struct s x)
/*
* check-name: mask1-setne0
* check-command: test-linearize -Wno-decl $file
- * check-known-to-fail
*
* check-output-start
foo: