intel/reg,fs: Handle immediates properly in subscript()

Just returning the original type isn't what we want in basically any
case.  Mask and shift the immediate as needed.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7329>
This commit is contained in:
Jason Ekstrand
2020-10-26 13:27:43 -05:00
committed by Marge Bot
parent e797daba53
commit 69a3559efd
3 changed files with 19 additions and 16 deletions

View File

@@ -2715,17 +2715,10 @@ fs_visitor::opt_algebraic()
assert(!inst->src[0].negate);
const brw::fs_builder ibld(this, block, inst);
if (inst->src[0].file == IMM) {
ibld.MOV(subscript(inst->dst, BRW_REGISTER_TYPE_UD, 1),
brw_imm_ud(inst->src[0].u64 >> 32));
ibld.MOV(subscript(inst->dst, BRW_REGISTER_TYPE_UD, 0),
brw_imm_ud(inst->src[0].u64));
} else {
ibld.MOV(subscript(inst->dst, BRW_REGISTER_TYPE_UD, 1),
subscript(inst->src[0], BRW_REGISTER_TYPE_UD, 1));
ibld.MOV(subscript(inst->dst, BRW_REGISTER_TYPE_UD, 0),
subscript(inst->src[0], BRW_REGISTER_TYPE_UD, 0));
}
inst->remove(block);
progress = true;

View File

@@ -303,8 +303,12 @@ subscript(fs_reg reg, brw_reg_type type, unsigned i)
reg.vstride += (reg.vstride ? delta : 0);
} else if (reg.file == IMM) {
assert(reg.type == type);
unsigned bit_size = type_sz(type) * 8;
reg.u64 >>= i * bit_size;
reg.u64 &= BITFIELD64_MASK(bit_size);
if (bit_size <= 16)
reg.u64 |= reg.u64 << 16;
return retype(reg, type);
} else {
reg.stride *= type_sz(reg.type) / type_sz(type);
}

View File

@@ -1022,12 +1022,18 @@ spread(struct brw_reg reg, unsigned s)
static inline struct brw_reg
subscript(struct brw_reg reg, enum brw_reg_type type, unsigned i)
{
if (reg.file == IMM)
return reg;
unsigned scale = type_sz(reg.type) / type_sz(type);
assert(scale >= 1 && i < scale);
if (reg.file == IMM) {
unsigned bit_size = type_sz(type) * 8;
reg.u64 >>= i * bit_size;
reg.u64 &= BITFIELD64_MASK(bit_size);
if (bit_size <= 16)
reg.u64 |= reg.u64 << 16;
return retype(reg, type);
}
return suboffset(retype(spread(reg, scale), type), i);
}