aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/simplify.c
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-07-08 23:59:51 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-07-28 09:06:47 +0200
commitbc0f5843abbc4579a277392af8db70f7835f4b97 (patch)
tree0bccb059e42748f2b3490a49730d7fc60909fa7c /simplify.c
parent0df976f9a48170c617f056e61381143342d9b939 (diff)
downloadsparse-dev-bc0f5843abbc4579a277392af8db70f7835f4b97.tar.gz
simplify SET{EQ,NE}(ZEXT(x, N),{0,1})
A zero-extension has no effect on the result of a comparison with 0 or 1. Optimize away the extension. Note: this simplification was already done but only when the original size was 1 but it can be done for all sizes. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'simplify.c')
-rw-r--r--simplify.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/simplify.c b/simplify.c
index b6c07ad9..fb63aa9b 100644
--- a/simplify.c
+++ b/simplify.c
@@ -608,16 +608,13 @@ static int simplify_seteq_setne(struct instruction *insn, long long value)
return REPEAT_CSE;
case OP_ZEXT:
- if (def->orig_type->bit_size == 1) {
- // Convert:
- // zext.m %s <- (1) %a
- // setne.1 %r <- %s, $0
- // into:
- // setne.1 %s <- %a, $0
- // and same for setne/eq ... 0/1
- return replace_pseudo(insn, &insn->src1, def->src1);
- }
- break;
+ // Convert:
+ // zext.m %s <- (1) %a
+ // setne.1 %r <- %s, $0
+ // into:
+ // setne.1 %s <- %a, $0
+ // and same for setne/eq ... 0/1
+ return replace_pseudo(insn, &insn->src1, def->src);
}
return 0;
}