This is another simple identity with the potential to trigger more simplifications. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- simplify.c | 2 ++ validation/optim/bits-not-zero.c | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/simplify.c b/simplify.c index 25e2a41c1..09cbe16dc 100644 --- a/simplify.c +++ b/simplify.c @@ -668,6 +668,8 @@ static int simplify_constant_rightside(struct instruction *insn) case OP_AND: if (!value) return replace_with_pseudo(insn, insn->src2); + if ((value & bits) == bits) + return replace_with_pseudo(insn, insn->src1); return 0; case OP_SET_NE: diff --git a/validation/optim/bits-not-zero.c b/validation/optim/bits-not-zero.c index 9872794b1..ce74705e8 100644 --- a/validation/optim/bits-not-zero.c +++ b/validation/optim/bits-not-zero.c @@ -1,4 +1,5 @@ int or_not0(int a) { return a | ~0; } +int and_not0(int a) { return a & ~0; } /* * check-name: bool-not-zero @@ -11,5 +12,11 @@ or_not0: ret.32 $0xffffffff +and_not0: +.L2: + <entry-point> + ret.32 %arg1 + + * check-output-end */ -- 2.18.0 -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html