aco: don't constant-propagate into subdword PSEUDO instructions
authorDaniel Schürmann <daniel@schuermann.dev>
Tue, 7 Apr 2020 09:46:37 +0000 (10:46 +0100)
committerMarge Bot <eric+marge@anholt.net>
Fri, 10 Apr 2020 07:19:27 +0000 (07:19 +0000)
PSEUDO instructions are lowered using SDWA, and thus,
cannot take literals and before GFX9 cannot take constants
at all. As the in-register representation differs between
32bit and 16bit floats, we first need to ensure correct
behavior.

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4492>

src/amd/compiler/aco_optimizer.cpp

index 72ae710f838b46f2d9921c7c8f605fe87f2ddfae..5e80d9afe7fca626d4dd29a61d3f1c26efb9ab4b 100644 (file)
@@ -699,13 +699,15 @@ void label_instruction(opt_ctx &ctx, Block& block, aco_ptr<Instruction>& instr)
 
       /* SALU / PSEUDO: propagate inline constants */
       if (instr->isSALU() || instr->format == Format::PSEUDO) {
+         const bool is_subdword = std::any_of(instr->definitions.begin(), instr->definitions.end(),
+                                              [] (const Definition& def) { return def.regClass().is_subdword();});
+         // TODO: optimize SGPR and constant propagation for subdword pseudo instructions on gfx9+
+         if (is_subdword)
+            continue;
+
          if (info.is_temp() && info.temp.type() == RegType::sgpr) {
-            const bool is_subdword = std::any_of(instr->definitions.begin(), instr->definitions.end(),
-                                                 [] (const Definition& def) { return def.regClass().is_subdword();});
-            if (instr->isSALU() || !is_subdword) {
-               instr->operands[i].setTemp(info.temp);
-               info = ctx.info[info.temp.id()];
-            }
+            instr->operands[i].setTemp(info.temp);
+            info = ctx.info[info.temp.id()];
          } else if (info.is_temp() && info.temp.type() == RegType::vgpr) {
             /* propagate vgpr if it can take it */
             switch (instr->opcode) {