diff options
| -rw-r--r-- | simplify.c | 17 | ||||
| -rw-r--r-- | validation/optim/and-trunc.c | 1 |
2 files changed, 11 insertions, 7 deletions
@@ -999,10 +999,18 @@ static int simplify_cast(struct instruction *insn) /* A cast of a AND might be a no-op.. */ switch (insn->opcode) { case OP_TRUNC: + if (nbr_users(src) > 1) + break; + def->opcode = OP_TRUNC; + def->orig_type = def->type; + def->type = insn->type; + def->size = size; + + insn->opcode = OP_AND; mask = val->value; - if (!(mask >> (size-1))) - goto simplify; - break; + mask &= (1ULL << size) - 1; + insn->src2 = value_pseudo(mask); + return REPEAT_CSE; } break; case OP_TRUNC: @@ -1029,9 +1037,6 @@ static int simplify_cast(struct instruction *insn) } return 0; - -simplify: - return replace_with_pseudo(insn, src); } static int simplify_select(struct instruction *insn) diff --git a/validation/optim/and-trunc.c b/validation/optim/and-trunc.c index bcb80bbe..df1e4d03 100644 --- a/validation/optim/and-trunc.c +++ b/validation/optim/and-trunc.c @@ -11,7 +11,6 @@ short umask(unsigned short x) /* * check-name: and-trunc * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-excludes: sext\\. |
