pan/mdg: Move constant switch opts to algebraic pass
No shader-db changes. Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4852>
This commit is contained in:
parent
1628c144a9
commit
23a20cfcf3
|
@ -2045,41 +2045,6 @@ inline_alu_constants(compiler_context *ctx, midgard_block *block)
|
|||
}
|
||||
}
|
||||
|
||||
/* Being a little silly with the names, but returns the op that is the bitwise
|
||||
* inverse of the op with the argument switched. I.e. (f and g are
|
||||
* contrapositives):
|
||||
*
|
||||
* f(a, b) = ~g(b, a)
|
||||
*
|
||||
* Corollary: if g is the contrapositve of f, f is the contrapositive of g:
|
||||
*
|
||||
* f(a, b) = ~g(b, a)
|
||||
* ~f(a, b) = g(b, a)
|
||||
* ~f(a, b) = ~h(a, b) where h is the contrapositive of g
|
||||
* f(a, b) = h(a, b)
|
||||
*
|
||||
* Thus we define this function in pairs.
|
||||
*/
|
||||
|
||||
static inline midgard_alu_op
|
||||
mir_contrapositive(midgard_alu_op op)
|
||||
{
|
||||
switch (op) {
|
||||
case midgard_alu_op_flt:
|
||||
return midgard_alu_op_fle;
|
||||
case midgard_alu_op_fle:
|
||||
return midgard_alu_op_flt;
|
||||
|
||||
case midgard_alu_op_ilt:
|
||||
return midgard_alu_op_ile;
|
||||
case midgard_alu_op_ile:
|
||||
return midgard_alu_op_ilt;
|
||||
|
||||
default:
|
||||
unreachable("No known contrapositive");
|
||||
}
|
||||
}
|
||||
|
||||
/* Midgard supports two types of constants, embedded constants (128-bit) and
|
||||
* inline constants (16-bit). Sometimes, especially with scalar ops, embedded
|
||||
* constants can be demoted to inline constants, for space savings and
|
||||
|
@ -2112,16 +2077,6 @@ embedded_to_inline_constant(compiler_context *ctx, midgard_block *block)
|
|||
bool flip = alu_opcode_props[op].props & OP_COMMUTES;
|
||||
|
||||
switch (op) {
|
||||
/* Conditionals can be inverted */
|
||||
case midgard_alu_op_flt:
|
||||
case midgard_alu_op_ilt:
|
||||
case midgard_alu_op_fle:
|
||||
case midgard_alu_op_ile:
|
||||
ins->alu.op = mir_contrapositive(ins->alu.op);
|
||||
ins->invert = true;
|
||||
flip = true;
|
||||
break;
|
||||
|
||||
case midgard_alu_op_fcsel:
|
||||
case midgard_alu_op_icsel:
|
||||
DBG("Missed non-commutative flip (%s)\n", alu_opcode_props[op].name);
|
||||
|
|
|
@ -92,6 +92,20 @@ SPECIAL = ['fexp2', 'flog2', 'fsin', 'fcos', 'frcp', 'frsq']
|
|||
for op in SPECIAL:
|
||||
converts += [((op + '@16', a), ('f2f16', (op, ('f2f32', a))))]
|
||||
|
||||
# Try to force constants to the right
|
||||
constant_switch = [
|
||||
# fge gets flipped to fle, so we invert to keep the order
|
||||
(('fge', 'a', '#b'), (('inot', ('flt', a, b)))),
|
||||
(('fge32', 'a', '#b'), (('inot', ('flt32', a, b)))),
|
||||
(('ige32', 'a', '#b'), (('inot', ('ilt32', a, b)))),
|
||||
(('uge32', 'a', '#b'), (('inot', ('ult32', a, b)))),
|
||||
|
||||
# fge gets mapped to fle with a flip
|
||||
(('flt32', '#a', 'b'), ('inot', ('fge32', a, b))),
|
||||
(('ilt32', '#a', 'b'), ('inot', ('ige32', a, b))),
|
||||
(('ult32', '#a', 'b'), ('inot', ('uge32', a, b)))
|
||||
]
|
||||
|
||||
# Midgard scales fsin/fcos arguments by pi.
|
||||
# Pass must be run only once, after the main loop
|
||||
|
||||
|
@ -114,7 +128,7 @@ def run():
|
|||
print('#include "midgard_nir.h"')
|
||||
|
||||
print(nir_algebraic.AlgebraicPass("midgard_nir_lower_algebraic_late",
|
||||
algebraic_late + converts).render())
|
||||
algebraic_late + converts + constant_switch).render())
|
||||
|
||||
print(nir_algebraic.AlgebraicPass("midgard_nir_scale_trig",
|
||||
scale_trig).render())
|
||||
|
|
Loading…
Reference in New Issue