[Beignet] [PATCH 1/5] GBE: disable mad for some cases.
Yang, Rong R
rong.r.yang at intel.com
Mon May 26 01:43:30 PDT 2014
Patch 1-4 of this patchset LGTM, thanks.
-----Original Message-----
From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of Zhigang Gong
Sent: Thursday, May 22, 2014 9:42 AM
To: beignet at lists.freedesktop.org
Cc: Gong, Zhigang
Subject: [Beignet] [PATCH 1/5] GBE: disable mad for some cases.
One case is one operand is an imm value. Then it turns to save one instruction but add an extra LOADI instruction.
We don't need to bother to use mad in this case.
And considering when we optimize the simd16 under simd8 mode, we
The other case is under simd16 mode. As mad is a 3-src instruction, which only support simd8, it will convert one mad(16) instruction to two mad(8) instructions. Then we don't need to use mad.
Signed-off-by: Zhigang Gong <zhigang.gong at intel.com>
---
backend/src/backend/gen_insn_selection.cpp | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/backend/src/backend/gen_insn_selection.cpp b/backend/src/backend/gen_insn_selection.cpp
index 7e245b8..e99dd4c 100644
--- a/backend/src/backend/gen_insn_selection.cpp
+++ b/backend/src/backend/gen_insn_selection.cpp
@@ -2255,7 +2255,7 @@ namespace gbe
// XXX TODO: we need a clean support of FP_CONTRACT to remove below line 'return false'
// if 'pragma FP_CONTRACT OFF' is used in cl kernel, we should not do mad optimization.
- if (!sel.ctx.relaxMath)
+ if (!sel.ctx.relaxMath || sel.ctx.getSimdWidth() == 16)
return false;
// MAD tend to increase liveness of the sources (since there are three of
// them). TODO refine this strategy. Well, we should be able at least to @@ -2273,6 +2273,12 @@ namespace gbe
const GenRegister dst = sel.selReg(insn.getDst(0), TYPE_FLOAT);
if (child0 && child0->insn.getOpcode() == OP_MUL) {
GBE_ASSERT(cast<ir::BinaryInstruction>(child0->insn).getType() == TYPE_FLOAT);
+ SelectionDAG *child00 = child0->child[0];
+ SelectionDAG *child01 = child0->child[1];
+ if ((child00 && child00->insn.getOpcode() == OP_LOADI) ||
+ (child01 && child01->insn.getOpcode() == OP_LOADI) ||
+ (child1 && child1->insn.getOpcode() == OP_LOADI))
+ return false;
const GenRegister src0 = sel.selReg(child0->insn.getSrc(0), TYPE_FLOAT);
const GenRegister src1 = sel.selReg(child0->insn.getSrc(1), TYPE_FLOAT);
GenRegister src2 = sel.selReg(insn.getSrc(1), TYPE_FLOAT); @@ -2285,6 +2291,12 @@ namespace gbe
}
if (child1 && child1->insn.getOpcode() == OP_MUL) {
GBE_ASSERT(cast<ir::BinaryInstruction>(child1->insn).getType() == TYPE_FLOAT);
+ SelectionDAG *child10 = child1->child[0];
+ SelectionDAG *child11 = child1->child[1];
+ if ((child10 && child10->insn.getOpcode() == OP_LOADI) ||
+ (child11 && child11->insn.getOpcode() == OP_LOADI) ||
+ (child0 && child0->insn.getOpcode() == OP_LOADI))
+ return false;
GenRegister src0 = sel.selReg(child1->insn.getSrc(0), TYPE_FLOAT);
const GenRegister src1 = sel.selReg(child1->insn.getSrc(1), TYPE_FLOAT);
const GenRegister src2 = sel.selReg(insn.getSrc(0), TYPE_FLOAT);
--
1.8.3.2
_______________________________________________
Beignet mailing list
Beignet at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list