aco/optimizer: Convert s_add_u32 with literals to s_add_i32 if carry is not used.
authorGeorg Lehmann <dadschoorse@gmail.com>
Sun, 17 Apr 2022 12:32:34 +0000 (14:32 +0200)
committerMarge Bot <emma+marge@anholt.net>
Wed, 6 Jul 2022 09:54:54 +0000 (09:54 +0000)
To allow further optimizations to s_addk_i32.

Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15999>

src/amd/compiler/aco_optimizer.cpp

index b4bf499..8af27ce 100644 (file)
@@ -4604,6 +4604,11 @@ apply_literals(opt_ctx& ctx, aco_ptr<Instruction>& instr)
       }
    }
 
+   /* allow more s_addk_i32 optimizations if carry isn't used */
+   if (instr->opcode == aco_opcode::s_add_u32 && ctx.uses[instr->definitions[1].tempId()] == 0 &&
+       (instr->operands[0].isLiteral() || instr->operands[1].isLiteral()))
+      instr->opcode = aco_opcode::s_add_i32;
+
    ctx.instructions.emplace_back(std::move(instr));
 }