pan/mdg: Copy-prop even with swizzle restrictions
Some instructions are not able to swizzle their sources, so we conservatively refused to propagate moves into them to avoid needing a swizzle on the source. This is too conservative: we only need to do this if the move swizzles. If there is only an identity swizzle on the move, we can propagate it without issue. This will mitigate some instruction count regression from the later modifier propagation, which will leave lots of moves that need to be propagated. total instructions in shared programs: 1514834 -> 1514477 (-0.02%) instructions in affected programs: 132297 -> 131940 (-0.27%) helped: 349 HURT: 3 Instructions are helped. total bundles in shared programs: 645093 -> 645069 (<.01%) bundles in affected programs: 9650 -> 9626 (-0.25%) helped: 42 HURT: 23 Bundles are helped. total quadwords in shared programs: 1130751 -> 1130469 (-0.02%) quadwords in affected programs: 78790 -> 78508 (-0.36%) helped: 269 HURT: 21 Quadwords are helped. total registers in shared programs: 90563 -> 90577 (0.02%) registers in affected programs: 163 -> 177 (8.59%) helped: 4 HURT: 16 Registers are HURT. total spills in shared programs: 1400 -> 1399 (-0.07%) spills in affected programs: 2 -> 1 (-50.00%) helped: 1 HURT: 0 total fills in shared programs: 5276 -> 5273 (-0.06%) fills in affected programs: 151 -> 148 (-1.99%) helped: 1 HURT: 3 Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Italo Nicola <italonicola@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23769>
This commit is contained in:
@@ -22,9 +22,25 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "util/bitscan.h"
|
||||
#include "compiler.h"
|
||||
#include "midgard_ops.h"
|
||||
|
||||
static bool
|
||||
identity_swizzle(midgard_instruction *mov)
|
||||
{
|
||||
/* Write mask should be minimal in SSA form */
|
||||
assert(mir_is_ssa(mov->src[1]));
|
||||
assert(mov->mask == BITFIELD_MASK(util_last_bit(mov->mask)));
|
||||
|
||||
for (unsigned i = 0; i < util_last_bit(mov->mask); ++i) {
|
||||
if (mov->swizzle[1][i] != i)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
midgard_opt_copy_prop(compiler_context *ctx, midgard_block *block)
|
||||
{
|
||||
@@ -65,7 +81,7 @@ midgard_opt_copy_prop(compiler_context *ctx, midgard_block *block)
|
||||
* component and even that is restricted. Fragment writeout
|
||||
* doesn't even get that much */
|
||||
|
||||
bool skip = false;
|
||||
bool no_swizzle = false;
|
||||
|
||||
mir_foreach_instr_global(ctx, q) {
|
||||
bool is_tex = q->type == TAG_TEXTURE_4;
|
||||
@@ -83,13 +99,13 @@ midgard_opt_copy_prop(compiler_context *ctx, midgard_block *block)
|
||||
|
||||
mir_foreach_src(q, s) {
|
||||
if ((s >= start) && q->src[s] == to) {
|
||||
skip = true;
|
||||
no_swizzle = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (skip)
|
||||
if (no_swizzle && !identity_swizzle(ins))
|
||||
continue;
|
||||
|
||||
if (ctx->blend_src1 == to)
|
||||
|
||||
Reference in New Issue
Block a user