aco: fix redirect combine in propagate_constants_vop3p() with negatives
authorRhys Perry <pendingchaos02@gmail.com>
Mon, 2 May 2022 12:16:54 +0000 (13:16 +0100)
committerMarge Bot <emma+marge@anholt.net>
Tue, 5 Jul 2022 16:39:56 +0000 (16:39 +0000)
This previously didn't correctly consider negative integers when bits=16
(which sign-extend) and would have combined 0xfffe0000.xy as -2.yx. Now it
combines 0xfffeffff.xy as that instead. It was also skipped when bits=32.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16296>

src/amd/compiler/aco_optimizer.cpp

index 88440c1..82dbf82 100644 (file)
@@ -949,12 +949,7 @@ propagate_constants_vop3p(opt_ctx& ctx, aco_ptr<Instruction>& instr, ssa_info& i
       /* opsel must point to lo for both halves */
       vop3p->opsel_lo &= ~(1 << i);
       vop3p->opsel_hi &= ~(1 << i);
-   } else if (const_lo == Operand::c16(0)) {
-      /* don't inline FP constants into integer instructions */
-      // TODO: check if negative integers are zero- or sign-extended
-      if (bits == 32 && const_hi.constantValue() > 64u)
-         return;
-
+   } else if (const_lo.constantValue() == const_hi.constantValue16(true)) {
       instr->operands[i] = const_hi;
 
       /* redirect opsel selection */