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:51:39 +0200
commit1a5e49c57e6585832c4197f4f2ed91c73a964cb9 (patch)
tree6473cd536120da23b77dbfc2d71b8b515ad02adf
parent8457b3c20a2f3e3f1ad1201af217faf4e89e0940 (diff)
downloadsparse-dev-1a5e49c57e6585832c4197f4f2ed91c73a964cb9.tar.gz
simplify ZEXT(SETCC(x,y), N)
Since the OP_SETCC instructions can only return a 0 or a 1, a zero-extension won't change the value and the OP_SETCC can be changed to directly return the extended size. Remove the unneeded extension. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--simplify.c13
-rw-r--r--validation/optim/bool-simplify.c9
-rw-r--r--validation/optim/setne0-zext.c1
-rw-r--r--validation/optim/trunc-seteq0.c1
4 files changed, 16 insertions, 8 deletions
diff --git a/simplify.c b/simplify.c
index 2ffe6ecb..ec9c5211 100644
--- a/simplify.c
+++ b/simplify.c
@@ -1189,6 +1189,19 @@ static int simplify_cast(struct instruction *insn)
return REPEAT_CSE;
}
break;
+ case OP_FPCMP ... OP_BINCMP_END:
+ switch (insn->opcode) {
+ case OP_ZEXT:
+ // simplify:
+ // setcc.n %t <- %a, %b
+ // zext.m %r <- (n) %t
+ // into:
+ // setcc.m %r <- %a, %b
+ insn->opcode = def->opcode;
+ use_pseudo(insn, def->src2, &insn->src2);
+ return replace_pseudo(insn, &insn->src1, def->src1);
+ }
+ break;
case OP_TRUNC:
osize = def->orig_type->bit_size;
if (insn->opcode == OP_ZEXT && size == osize) {
diff --git a/validation/optim/bool-simplify.c b/validation/optim/bool-simplify.c
index 68aabb78..b872764c 100644
--- a/validation/optim/bool-simplify.c
+++ b/validation/optim/bool-simplify.c
@@ -43,16 +43,14 @@ and_0:
and_1:
.L2:
<entry-point>
- setne.1 %r8 <- %arg1, $0
- zext.32 %r11 <- (1) %r8
+ setne.32 %r11 <- %arg1, $0
ret.32 %r11
or_0:
.L4:
<entry-point>
- setne.1 %r14 <- %arg1, $0
- zext.32 %r17 <- (1) %r14
+ setne.32 %r17 <- %arg1, $0
ret.32 %r17
@@ -65,8 +63,7 @@ or_1:
and_2:
.L8:
<entry-point>
- setne.1 %r26 <- %arg1, $0
- zext.32 %r29 <- (1) %r26
+ setne.32 %r29 <- %arg1, $0
ret.32 %r29
diff --git a/validation/optim/setne0-zext.c b/validation/optim/setne0-zext.c
index fc6615be..8a074f03 100644
--- a/validation/optim/setne0-zext.c
+++ b/validation/optim/setne0-zext.c
@@ -3,7 +3,6 @@ unsigned long foo(int a) { return (unsigned int) (a != 0); }
/*
* check-name: setne0-zext
* check-command: test-linearize -m64 -Wno-decl $file
- * check-known-to-fail
*
* check-output-ignore
* check-output-excludes: zext\\.
diff --git a/validation/optim/trunc-seteq0.c b/validation/optim/trunc-seteq0.c
index 321c045e..5994b17c 100644
--- a/validation/optim/trunc-seteq0.c
+++ b/validation/optim/trunc-seteq0.c
@@ -10,7 +10,6 @@ int ou(int i, struct S *b) { return i || b->u; }
/*
* check-name: trunc-seteq0
* check-command: test-linearize -Wno-decl $file
- * check-known-to-fail
*
* check-output-ignore
* check-output-excludes: trunc\\.