Mesa (master): gv100/ir: fix shift lowering

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Jun 21 23:20:56 UTC 2020


Module: Mesa
Branch: master
Commit: 42b9aa5f5c77390c88b17b226982a27bd1dd6c7e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=42b9aa5f5c77390c88b17b226982a27bd1dd6c7e

Author: Karol Herbst <kherbst at redhat.com>
Date:   Sat Jun 20 16:52:44 2020 +0200

gv100/ir: fix shift lowering

Wrap was ignored. Also merge functions to share code.

Signed-off-by: Karol Herbst <kherbst at redhat.com>
Reviewed-by: Ben Skeggs <bskeggs at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5576>

---

 .../nouveau/codegen/nv50_ir_lowering_gv100.cpp     | 33 +++++++++++-----------
 .../nouveau/codegen/nv50_ir_lowering_gv100.h       |  3 +-
 2 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_gv100.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_gv100.cpp
index 4b6df0db588..953f082a06a 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_gv100.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_gv100.cpp
@@ -206,24 +206,25 @@ GV100LegalizeSSA::handleSHFL(Instruction *i)
 }
 
 bool
-GV100LegalizeSSA::handleSHL(Instruction *i)
+GV100LegalizeSSA::handleShift(Instruction *i)
 {
-   if (i->src(0).getFile() != FILE_GPR) {
-      bld.mkOp3(OP_SHF, i->dType, i->getDef(0), bld.mkImm(0), i->getSrc(1),
-                i->getSrc(0))->subOp = NV50_IR_SUBOP_SHF_L |
-                                       NV50_IR_SUBOP_SHF_HI;
+   Value *zero = bld.mkImm(0);
+   Value *src1 = i->getSrc(1);
+   Value *src0, *src2;
+   uint8_t subOp = i->op == OP_SHL ? NV50_IR_SUBOP_SHF_L : NV50_IR_SUBOP_SHF_R;
+
+   if (i->op == OP_SHL && i->src(0).getFile() == FILE_GPR) {
+      src0 = i->getSrc(0);
+      src2 = zero;
    } else {
-      bld.mkOp3(OP_SHF, i->dType, i->getDef(0), i->getSrc(0), i->getSrc(1),
-                bld.mkImm(0))->subOp = NV50_IR_SUBOP_SHF_L;
+      src0 = zero;
+      src2 = i->getSrc(0);
+      subOp |= NV50_IR_SUBOP_SHF_HI;
    }
-   return true;
-}
+   if (i->subOp & NV50_IR_SUBOP_SHIFT_WRAP)
+      subOp |= NV50_IR_SUBOP_SHF_W;
 
-bool
-GV100LegalizeSSA::handleSHR(Instruction *i)
-{
-   bld.mkOp3(OP_SHF, i->dType, i->getDef(0), bld.mkImm(0), i->getSrc(1),
-             i->getSrc(0))->subOp = NV50_IR_SUBOP_SHF_R | NV50_IR_SUBOP_SHF_HI;
+   bld.mkOp3(OP_SHF, i->dType, i->getDef(0), src0, src1, src2)->subOp = subOp;
    return true;
 }
 
@@ -255,10 +256,8 @@ GV100LegalizeSSA::visit(Instruction *i)
       lowered = handleNOT(i);
       break;
    case OP_SHL:
-      lowered = handleSHL(i);
-      break;
    case OP_SHR:
-      lowered = handleSHR(i);
+      lowered = handleShift(i);
       break;
    case OP_SET:
    case OP_SET_AND:
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_gv100.h b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_gv100.h
index 92fdb938244..d918c6e83eb 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_gv100.h
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_gv100.h
@@ -71,8 +71,7 @@ private:
    bool handleQUADPOP(Instruction *);
    bool handleSET(Instruction *);
    bool handleSHFL(Instruction *);
-   bool handleSHL(Instruction *);
-   bool handleSHR(Instruction *);
+   bool handleShift(Instruction *);
    bool handleSUB(Instruction *);
 };
 }



More information about the mesa-commit mailing list