i915g: Handle constants composed exclusively of 0 or ±1 specially

This can avoid some cases where a constant has to be loaded into a
temporary register.

v2: Update i915-g33-fails.txt.

total instructions in shared programs: 788625 -> 782376 (-0.79%)
instructions in affected programs: 166269 -> 160020 (-3.76%)
helped: 1578
HURT: 0
helped stats (abs) min: 3 max: 21 x̄: 3.96 x̃: 3
helped stats (rel) min: 1.56% max: 33.33% x̄: 4.82% x̃: 3.45%
95% mean confidence interval for instructions value: -4.06 -3.86
95% mean confidence interval for instructions %-change: -5.00% -4.64%
Instructions are helped.

LOST:   0
GAINED: 35

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15210>
This commit is contained in:
Ian Romanick 2022-03-01 15:48:51 -08:00 committed by Marge Bot
parent 06eb9fb125
commit 374da6fc41
2 changed files with 41 additions and 2 deletions

View File

@ -43,7 +43,6 @@ dEQP-GLES2.functional.shaders.loops.for_constant_iterations.conditional_continue
dEQP-GLES2.functional.shaders.loops.for_constant_iterations.double_continue_fragment,Fail
dEQP-GLES2.functional.shaders.loops.for_constant_iterations.mixed_break_continue_fragment,Fail
dEQP-GLES2.functional.shaders.random.all_features.fragment.22,Fail
dEQP-GLES2.functional.shaders.random.all_features.fragment.38,Fail
dEQP-GLES2.functional.shaders.random.all_features.fragment.5,Fail
dEQP-GLES2.functional.shaders.random.all_features.fragment.79,Fail

View File

@ -200,10 +200,50 @@ src_vector(struct i915_fp_compile *p,
}
break;
case TGSI_FILE_IMMEDIATE:
case TGSI_FILE_IMMEDIATE: {
assert(index < p->num_immediates);
uint8_t swiz[4] = {
source->Register.SwizzleX,
source->Register.SwizzleY,
source->Register.SwizzleZ,
source->Register.SwizzleW
};
uint8_t neg[4] = {
source->Register.Negate,
source->Register.Negate,
source->Register.Negate,
source->Register.Negate
};
unsigned i;
for (i = 0; i < 4; i++) {
if (swiz[i] == TGSI_SWIZZLE_ZERO || swiz[i] == TGSI_SWIZZLE_ONE) {
continue;
} else if (p->immediates[index][swiz[i]] == 0.0) {
swiz[i] = TGSI_SWIZZLE_ZERO;
} else if (p->immediates[index][swiz[i]] == 1.0) {
swiz[i] = TGSI_SWIZZLE_ONE;
} else if (p->immediates[index][swiz[i]] == -1.0) {
swiz[i] = TGSI_SWIZZLE_ONE;
neg[i] ^= 1;
} else {
break;
}
}
if (i == 4) {
return negate(swizzle(UREG(REG_TYPE_R, 0),
swiz[0], swiz[1], swiz[2], swiz[3]),
neg[0], neg[1], neg[2], neg[3]);
}
index = p->immediates_map[index];
FALLTHROUGH;
}
case TGSI_FILE_CONSTANT:
src = UREG(REG_TYPE_CONST, index);
break;