From 871389f906d6f6d33703851eee7111390c562bc5 Mon Sep 17 00:00:00 2001 From: Ruiling Song Date: Fri, 30 May 2014 16:22:30 +0800 Subject: [PATCH] GBE: Fix bitcast between long and other type. As we store long low/high 32bits separately, when we do bitcast like int64 --> int16, the horizontal stride of the int64's low/high half should be set as 2 instead of 4. This fix an regression of opencv test: Imgproc/Threshold.Mat/40, where GetParam() = (16SC1, 0, 0, false) Signed-off-by: Ruiling Song Reviewed-by: Zhigang Gong --- backend/src/backend/gen_insn_selection.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/backend/src/backend/gen_insn_selection.cpp b/backend/src/backend/gen_insn_selection.cpp index b651c19..3530d2c 100644 --- a/backend/src/backend/gen_insn_selection.cpp +++ b/backend/src/backend/gen_insn_selection.cpp @@ -3090,7 +3090,7 @@ namespace gbe wideReg = sel.selReg(insn.getDst(index/multiple), narrowType); narrowReg = sel.selReg(insn.getSrc(i), narrowType); //retype to narrow type } - if(wideReg.hstride != GEN_VERTICAL_STRIDE_0) { + if(wideReg.hstride != GEN_HORIZONTAL_STRIDE_0) { if(multiple == 2) { wideReg = sel.unpacked_uw(wideReg.reg()); wideReg = GenRegister::retype(wideReg, getGenType(narrowType)); @@ -3107,6 +3107,15 @@ namespace gbe wideReg.subphysical = 1; } if(isInt64) { + if(wideReg.hstride != GEN_HORIZONTAL_STRIDE_0) { + // as we store long by bottom & high part separately, we have to divide hstride by 2 + if (wideReg.hstride == GEN_HORIZONTAL_STRIDE_2) + wideReg.hstride = GEN_HORIZONTAL_STRIDE_1; + else if (wideReg.hstride == GEN_HORIZONTAL_STRIDE_4) + wideReg.hstride = GEN_HORIZONTAL_STRIDE_2; + else + GBE_ASSERT(0); + } // offset to next half wideReg.subphysical = 1; if(i >= multiple/2) -- 2.7.4