diff options
| -rw-r--r-- | simplify.c | 17 | ||||
| -rw-r--r-- | validation/optim/double-unop.c | 15 |
2 files changed, 32 insertions, 0 deletions
@@ -651,6 +651,23 @@ static int simplify_unop(struct instruction *insn) return REPEAT_CSE; if (constant(insn->src1)) return simplify_constant_unop(insn); + + switch (insn->opcode) { + struct instruction *def; + + case OP_NOT: + def = insn->src->def; + if (def && def->opcode == OP_NOT) + return replace_with_pseudo(insn, def->src); + break; + case OP_NEG: + def = insn->src->def; + if (def && def->opcode == OP_NEG) + return replace_with_pseudo(insn, def->src); + break; + default: + return 0; + } return 0; } diff --git a/validation/optim/double-unop.c b/validation/optim/double-unop.c new file mode 100644 index 00000000..f0e6d94f --- /dev/null +++ b/validation/optim/double-unop.c @@ -0,0 +1,15 @@ +typedef unsigned int u32; + +u32 unotnot(u32 a) { return ~(~a); } +int snotnot(int a) { return ~(~a); } +u32 unegneg(int a) { return -(-a); } +int snegneg(int a) { return -(-a); } + +/* + * check-name: double-unop + * check-command: test-linearize -Wno-decl $file + * check-output-ignore + * + * check-output-excludes: not\\. + * check-output-excludes: neg\\. + */ |
