@@ -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:
@@ -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
*/
This is another simple identity with the potential to trigger more simplifications. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> --- simplify.c | 2 ++ validation/optim/bits-not-zero.c | 7 +++++++ 2 files changed, 9 insertions(+)