aco: fix propagate_constants_vop3p with integer vop3p and 16-bit constants
authorRhys Perry <pendingchaos02@gmail.com>
Mon, 2 May 2022 12:10:47 +0000 (13:10 +0100)
committerMarge Bot <emma+marge@anholt.net>
Tue, 5 Jul 2022 16:39:56 +0000 (16:39 +0000)
This would have created a 1.0.xx operand from 0x3c00.xx or 0x3c003c00.xy
for vop3p instructions which have 32-bit operands.

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 26cb5ca..b844de2 100644 (file)
@@ -914,8 +914,11 @@ propagate_constants_vop3p(opt_ctx& ctx, aco_ptr<Instruction>& instr, ssa_info& i
 
    /* try to fold inline constants */
    VOP3P_instruction* vop3p = &instr->vop3p();
-   Operand const_lo = Operand::c16(info.val);
-   Operand const_hi = Operand::c16(info.val >> 16);
+   /* TODO: if bits==32, we might be able to get an inline constant if we sign-extend or shift left
+    * 16 bits.
+    */
+   Operand const_lo = Operand::get_const(ctx.program->gfx_level, info.val & 0xffff, bits / 8u);
+   Operand const_hi = Operand::get_const(ctx.program->gfx_level, info.val >> 16, bits / 8u);
    bool opsel_lo = (vop3p->opsel_lo >> i) & 1;
    bool opsel_hi = (vop3p->opsel_hi >> i) & 1;