Skip to content

etnaviv: immediate negation

Philipp Zabel requested to merge pH5/mesa:etnaviv-immediate-negation into main

Immediate values in GC3000 ALU instructions do not support the negation flag as they occupy the same bits. Extend const_src() / get_src() with a negation parameter to allow negating the immediate values instead.

This fixes an assertion when running glmark2 -b terrain on GC3000:

src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c:505: emit_alu: Assertion `!asrc->negate && alu->op != nir_op_fneg' failed.

which was likely introduced by commit 45a111c2 ("nir/opt_algebraic: Fuse c - a * b to FMA"). This optimization nicely shrinks the shaders for this benchmark but introduces several negate flagged ALU uses of a constant that can be immediate on GC3000:

vec1 32 ssa_5 = load_const (0x43908000 = 289.000000)
...
vec3 32 ssa_753 = ffma -ssa_5.xxx, ssa_58, ssa_32
...
vec4 32 ssa_750 = ffma -ssa_5.xxxx, ssa_68, ssa_71
...
Edited by Philipp Zabel

Merge request reports