r600/sfn: resolve constant indices into local arrays better

When the code is first generated constants are loaded to registers, so to
avoid indirect array register access that can be resolved as a direct direct
access we have to check whether the address register is loaded
with a constant value.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36488>
This commit is contained in:
Gert Wollny 2025-07-31 23:44:12 +02:00 committed by Marge Bot
parent 874005aeb7
commit 356bc41797

View file

@ -9,6 +9,7 @@
#include "sfn_alu_defines.h"
#include "sfn_debug.h"
#include "sfn_instr.h"
#include "sfn_instr_alu.h"
#include "sfn_valuefactory.h"
#include "util/macros.h"
#include "util/u_math.h"
@ -908,7 +909,17 @@ LocalArray::element(size_t offset, PVirtualValue indirect, uint32_t chan)
if (indirect) {
class ResolveDirectArrayElement : public ConstRegisterVisitor {
public:
void visit(const Register& value) { (void)value; };
void visit(const Register& value)
{
if (value.has_flag(Register::ssa)) {
assert(value.parents().size() == 1);
auto p = (*value.parents().begin())->as_alu();
if (p && p->can_propagate_src()) {
auto& s = p->src(0);
s.accept(*this);
}
}
}
void visit(const LocalArray& value)
{
(void)value;
@ -921,7 +932,20 @@ LocalArray::element(size_t offset, PVirtualValue indirect, uint32_t chan)
offset = value.value();
is_contant = true;
}
void visit(const InlineConstant& value) { (void)value; }
void visit(const InlineConstant& value)
{
switch (value.sel()) {
case ALU_SRC_0:
offset = 0;
is_contant = true;
break;
case ALU_SRC_1_INT:
offset = 1;
is_contant = true;
break;
default:;
}
}
ResolveDirectArrayElement():
offset(0),