From: Ilia Mirkin Date: Tue, 8 Dec 2015 21:48:06 +0000 (-0500) Subject: nv50/ir: check if the target supports the new offset before inlining X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0f647bd65bae16c7a2dc7a960c96593ad6ab729c;p=mesa.git nv50/ir: check if the target supports the new offset before inlining Fixes: abd326e81b (nv50/ir: propagate indirect loads into instructions) Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93300 Signed-off-by: Ilia Mirkin --- diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp index 2f21257d88a..805be5fcb40 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp @@ -290,20 +290,23 @@ IndirectPropagation::visit(BasicBlock *bb) continue; if (insn->op == OP_ADD && !isFloatType(insn->dType)) { if (insn->src(0).getFile() != targ->nativeFile(FILE_ADDRESS) || - !insn->src(1).getImmediate(imm)) + !insn->src(1).getImmediate(imm) || + !targ->insnCanLoadOffset(i, s, imm.reg.data.s32)) continue; i->setIndirect(s, 0, insn->getSrc(0)); i->setSrc(s, cloneShallow(func, i->getSrc(s))); i->src(s).get()->reg.data.offset += imm.reg.data.u32; } else if (insn->op == OP_SUB && !isFloatType(insn->dType)) { if (insn->src(0).getFile() != targ->nativeFile(FILE_ADDRESS) || - !insn->src(1).getImmediate(imm)) + !insn->src(1).getImmediate(imm) || + !targ->insnCanLoadOffset(i, s, -imm.reg.data.s32)) continue; i->setIndirect(s, 0, insn->getSrc(0)); i->setSrc(s, cloneShallow(func, i->getSrc(s))); i->src(s).get()->reg.data.offset -= imm.reg.data.u32; } else if (insn->op == OP_MOV) { - if (!insn->src(0).getImmediate(imm)) + if (!insn->src(0).getImmediate(imm) || + !targ->insnCanLoadOffset(i, s, imm.reg.data.s32)) continue; i->setIndirect(s, 0, NULL); i->setSrc(s, cloneShallow(func, i->getSrc(s))); diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_target.h b/src/gallium/drivers/nouveau/codegen/nv50_ir_target.h index 4e33997e1c1..673f8811ff3 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_target.h +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_target.h @@ -191,6 +191,8 @@ public: virtual bool insnCanLoad(const Instruction *insn, int s, const Instruction *ld) const = 0; + virtual bool insnCanLoadOffset(const Instruction *insn, int s, + int offset) const { return true; } virtual bool isOpSupported(operation, DataType) const = 0; virtual bool isAccessSupported(DataFile, DataType) const = 0; virtual bool isModSupported(const Instruction *, diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp index 2d5baede2e0..101082e7491 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp @@ -384,6 +384,21 @@ TargetNV50::insnCanLoad(const Instruction *i, int s, return true; } +bool +TargetNV50::insnCanLoadOffset(const Instruction *i, int s, int offset) const +{ + if (!i->src(s).isIndirect(0)) + return true; + offset += i->src(s).get()->reg.data.offset; + if (i->op == OP_LOAD || i->op == OP_STORE) { + // There are some restrictions in theory, but in practice they're never + // going to be hit. When we enable shared/global memory, this will + // become more important. + return true; + } + return offset >= 0 && offset <= (int32_t)(127 * i->src(s).get()->reg.size); +} + bool TargetNV50::isAccessSupported(DataFile file, DataType ty) const { diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.h b/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.h index 0cbf180d048..00243d7958e 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.h +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.h @@ -46,6 +46,8 @@ public: virtual bool insnCanLoad(const Instruction *insn, int s, const Instruction *ld) const; + virtual bool insnCanLoadOffset(const Instruction *insn, int s, + int offset) const; virtual bool isOpSupported(operation, DataType) const; virtual bool isAccessSupported(DataFile, DataType) const; virtual bool isModSupported(const Instruction *, int s, Modifier) const;