+ if (is_zero(c, inst->src[1])) {
+ replace_with_mov(c, inst, inst->src[0]);
+ progress = true;
+ }
+ break;
+
+ case QOP_ADD:
+ /* Kernel validation requires that we use an actual
+ * add instruction.
+ */
+ if (inst->dst.file != QFILE_TEX_S_DIRECT &&
+ (replace_x_0_with_x(c, inst, 0) ||
+ replace_x_0_with_x(c, inst, 1))) {
+ progress = true;
+ break;
+ }
+ break;
+
+ case QOP_FADD:
+ if (replace_x_0_with_x(c, inst, 0) ||
+ replace_x_0_with_x(c, inst, 1)) {
+ progress = true;
+ break;
+ }
+
+ /* FADD(a, FSUB(0, b)) -> FSUB(a, b) */
+ if (inst->src[1].file == QFILE_TEMP &&
+ c->defs[inst->src[1].index] &&
+ c->defs[inst->src[1].index]->op == QOP_FSUB) {
+ struct qinst *fsub = c->defs[inst->src[1].index];
+ if (is_zero(c, fsub->src[0])) {
+ dump_from(c, inst);
+ inst->op = QOP_FSUB;
+ inst->src[1] = fsub->src[1];
+ progress = true;
+ dump_to(c, inst);
+ break;
+ }
+ }
+
+ /* FADD(FSUB(0, b), a) -> FSUB(a, b) */
+ if (inst->src[0].file == QFILE_TEMP &&
+ c->defs[inst->src[0].index] &&
+ c->defs[inst->src[0].index]->op == QOP_FSUB) {
+ struct qinst *fsub = c->defs[inst->src[0].index];
+ if (is_zero(c, fsub->src[0])) {
+ dump_from(c, inst);
+ inst->op = QOP_FSUB;
+ inst->src[0] = inst->src[1];
+ inst->src[1] = fsub->src[1];
+ dump_to(c, inst);
+ progress = true;
+ break;
+ }
+ }
+ break;
+
+ case QOP_FMUL:
+ if (!inst->dst.pack &&
+ (replace_x_0_with_0(c, inst, 0) ||
+ replace_x_0_with_0(c, inst, 1) ||
+ fmul_replace_one(c, inst, 0) ||
+ fmul_replace_one(c, inst, 1))) {
+ progress = true;
+ break;
+ }
+ break;
+
+ case QOP_MUL24:
+ if (!inst->dst.pack &&
+ (replace_x_0_with_0(c, inst, 0) ||
+ replace_x_0_with_0(c, inst, 1))) {
+ progress = true;
+ break;
+ }
+ break;
+
+ case QOP_AND:
+ if (replace_x_0_with_0(c, inst, 0) ||
+ replace_x_0_with_0(c, inst, 1)) {
+ progress = true;
+ break;
+ }
+
+ if (is_constant_value(c, inst->src[0], ~0)) {
+ replace_with_mov(c, inst, inst->src[1]);
+ progress = true;
+ break;
+ }
+ if (is_constant_value(c, 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, inst, 0) ||
+ replace_x_0_with_x(c, inst, 1)) {
+ progress = true;
+ break;
+ }
+ break;
+
+ case QOP_RCP:
+ if (is_1f(c, inst->src[0])) {
+ replace_with_mov(c, inst, inst->src[0]);