ir3: Copy-propagate single-source phis

These can be created when removing unreachable control flow, and it
seems easier to remove them than to add special code to handle them when
spilling.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12033>
This commit is contained in:
Connor Abbott 2021-07-23 11:45:10 +02:00 committed by Marge Bot
parent f40baf33e6
commit d25cf483cb
2 changed files with 5 additions and 2 deletions

View file

@ -801,6 +801,8 @@ is_same_type_mov(struct ir3_instruction *instr)
if (!is_same_type_reg(instr->dsts[0], instr->srcs[0]))
return false;
break;
case OPC_META_PHI:
return instr->srcs_count == 1;
default:
return false;
}

View file

@ -536,11 +536,12 @@ instr_cp(struct ir3_cp_ctx *ctx, struct ir3_instruction *instr)
/* TODO non-indirect access we could figure out which register
* we actually want and allow cp..
*/
if (reg->flags & IR3_REG_ARRAY)
if ((reg->flags & IR3_REG_ARRAY) && src->opc != OPC_META_PHI)
continue;
/* Don't CP absneg into meta instructions, that won't end well: */
if (is_meta(instr) && (src->opc != OPC_MOV))
if (is_meta(instr) &&
(src->opc == OPC_ABSNEG_F || src->opc == OPC_ABSNEG_S))
continue;
/* Don't CP mova and mova1 into their users */