aco: don't propagate vgprs into v_readlane/v_writelane
authorRhys Perry <pendingchaos02@gmail.com>
Tue, 12 Nov 2019 15:53:15 +0000 (15:53 +0000)
committerRhys Perry <pendingchaos02@gmail.com>
Tue, 12 Nov 2019 17:21:38 +0000 (17:21 +0000)
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Fixes: 93c8ebfa ('aco: Initial commit of independent AMD compiler')
src/amd/compiler/aco_optimizer.cpp

index 679f25b5dda8e82fad632eacacc9f9e4fa460081..68f17569e329b2e0318b0834242304013e073067 100644 (file)
@@ -474,6 +474,13 @@ bool valu_can_accept_literal(opt_ctx& ctx, aco_ptr<Instruction>& instr, unsigned
           operand == 0 && can_accept_constant(instr, operand);
 }
 
+bool valu_can_accept_vgpr(aco_ptr<Instruction>& instr, unsigned operand)
+{
+   if (instr->opcode == aco_opcode::v_readlane_b32 || instr->opcode == aco_opcode::v_writelane_b32)
+      return operand != 1;
+   return true;
+}
+
 bool parse_base_offset(opt_ctx &ctx, Instruction* instr, unsigned op_index, Temp *base, uint32_t *offset)
 {
    Operand op = instr->operands[op_index];
@@ -579,7 +586,7 @@ void label_instruction(opt_ctx &ctx, aco_ptr<Instruction>& instr)
 
       /* VALU: propagate neg, abs & inline constants */
       else if (instr->isVALU()) {
-         if (info.is_temp() && info.temp.type() == RegType::vgpr) {
+         if (info.is_temp() && info.temp.type() == RegType::vgpr && valu_can_accept_vgpr(instr, i)) {
             instr->operands[i].setTemp(info.temp);
             info = ctx.info[info.temp.id()];
          }