*/
swap(instr->regs[0 + 1], instr->regs[1 + 1]);
+ /* cat3 doesn't encode immediate, but we can lower immediate
+ * to const if that helps:
+ */
+ if (new_flags & IR3_REG_IMMED) {
+ new_flags &= ~IR3_REG_IMMED;
+ new_flags |= IR3_REG_CONST;
+ }
+
bool valid_swap =
/* can we propagate mov if we move 2nd src to first? */
valid_flags(instr, 0, new_flags) &&
iim_val = ~iim_val;
/* other than category 1 (mov) we can only encode up to 10 bits: */
- if ((instr->opc == OPC_MOV) ||
- !((iim_val & ~0x3ff) && (-iim_val & ~0x3ff))) {
+ if (valid_flags(instr, n, new_flags) &&
+ ((instr->opc == OPC_MOV) ||
+ !((iim_val & ~0x3ff) && (-iim_val & ~0x3ff)))) {
new_flags &= ~(IR3_REG_SABS | IR3_REG_SNEG | IR3_REG_BNOT);
src_reg = ir3_reg_clone(instr->block->shader, src_reg);
src_reg->flags = new_flags;