}
static bool
-add_replace_zero(struct vc4_compile *c,
+replace_x_0_with_x(struct vc4_compile *c,
struct qinst **defs,
struct qinst *inst,
int arg)
}
static bool
-fmul_replace_zero(struct vc4_compile *c,
+replace_x_0_with_0(struct vc4_compile *c,
struct qinst **defs,
struct qinst *inst,
int arg)
break;
case QOP_ADD:
- if (add_replace_zero(c, defs, inst, 0) ||
- add_replace_zero(c, defs, inst, 1)) {
+ if (replace_x_0_with_x(c, defs, inst, 0) ||
+ replace_x_0_with_x(c, defs, inst, 1)) {
progress = true;
break;
}
break;
case QOP_FADD:
- if (add_replace_zero(c, defs, inst, 0) ||
- add_replace_zero(c, defs, inst, 1)) {
+ if (replace_x_0_with_x(c, defs, inst, 0) ||
+ replace_x_0_with_x(c, defs, inst, 1)) {
progress = true;
break;
}
break;
case QOP_FMUL:
- if (fmul_replace_zero(c, defs, inst, 0) ||
- fmul_replace_zero(c, defs, inst, 1) ||
+ if (replace_x_0_with_0(c, defs, inst, 0) ||
+ replace_x_0_with_0(c, defs, inst, 1) ||
fmul_replace_one(c, defs, inst, 0) ||
fmul_replace_one(c, defs, inst, 1)) {
progress = true;
}
break;
+ case QOP_AND:
+ if (replace_x_0_with_0(c, defs, inst, 0) ||
+ replace_x_0_with_0(c, defs, inst, 1)) {
+ progress = true;
+ break;
+ }
+
+ if (is_constant_value(c, defs, inst->src[0], ~0)) {
+ replace_with_mov(c, inst, inst->src[1]);
+ progress = true;
+ break;
+ }
+ if (is_constant_value(c, defs, inst->src[1], ~0)) {
+ replace_with_mov(c, inst, inst->src[0]);
+ progress = true;
+ break;
+ }
+ break;
+
+ case QOP_OR:
+ if (replace_x_0_with_x(c, defs, inst, 0) ||
+ replace_x_0_with_x(c, defs, inst, 1)) {
+ progress = true;
+ break;
+ }
+ break;
+
default:
break;
}