[Beignet] [PATCH] Remove boolean values cannot cross their definition basic block restrict.
Zhigang Gong
zhigang.gong at linux.intel.com
Wed Nov 13 18:51:29 PST 2013
LGTM, pushed, thanks.
On Thu, Nov 14, 2013 at 11:14:33AM +0800, Yang Rong wrote:
> Add mov bool support.
>
> Signed-off-by: Yang Rong <rong.r.yang at intel.com>
> ---
> backend/src/backend/gen_insn_selection.cpp | 23 ++++++++++++++++++++++-
> backend/src/ir/instruction.cpp | 2 ++
> backend/src/llvm/llvm_gen_backend.cpp | 2 --
> utests/compiler_bool_cross_basic_block.cpp | 2 +-
> 4 files changed, 25 insertions(+), 4 deletions(-)
>
> diff --git a/backend/src/backend/gen_insn_selection.cpp b/backend/src/backend/gen_insn_selection.cpp
> index f6f7961..5a6b9fd 100644
> --- a/backend/src/backend/gen_insn_selection.cpp
> +++ b/backend/src/backend/gen_insn_selection.cpp
> @@ -1458,6 +1458,7 @@ namespace gbe
> case TYPE_U8: return GenRegister::immuw(imm.data.u8);
> case TYPE_S8: return GenRegister::immw(imm.data.s8);
> case TYPE_DOUBLE: return GenRegister::immdf(imm.data.f64);
> + case TYPE_BOOL: return GenRegister::immuw(-imm.data.b); //return 0xffff when true
> default: NOT_SUPPORTED; return GenRegister::immuw(0);
> }
> }
> @@ -1502,6 +1503,8 @@ namespace gbe
> return ir::TYPE_U32;
> if (insnType == ir::TYPE_S16 || insnType == ir::TYPE_U16)
> return insnType;
> + if (insnType == ir::TYPE_BOOL)
> + return ir::TYPE_U16;
> return ir::TYPE_FLOAT;
> }
>
> @@ -1522,7 +1525,25 @@ namespace gbe
> }
> break;
> case ir::OP_MOV:
> - if (dst.isdf()) {
> + if(insn.getType() == ir::TYPE_BOOL) {
> + GenRegister flagReg;
> + uint32_t predicate = sel.curr.predicate;
> + sel.push();
> + sel.curr.execWidth = 1;
> + sel.curr.predicate = GEN_PREDICATE_NONE;
> + sel.curr.noMask = 1;
> + if(predicate == GEN_PREDICATE_NONE)
> + sel.MOV(dst, src);
> + else {
> + if(sel.curr.physicalFlag)
> + flagReg = GenRegister::flag(sel.curr.flag, sel.curr.subFlag);
> + else
> + flagReg = sel.selReg(ir::Register(sel.curr.flagIndex), ir::TYPE_U16);
> +
> + sel.AND(dst, flagReg, src);
> + }
> + sel.pop();
> + } else if (dst.isdf()) {
> ir::Register r = sel.reg(ir::RegisterFamily::FAMILY_QWORD);
> sel.MOV_DF(dst, src, sel.selReg(r));
> } else
> diff --git a/backend/src/ir/instruction.cpp b/backend/src/ir/instruction.cpp
> index 61dcd49..da20d43 100644
> --- a/backend/src/ir/instruction.cpp
> +++ b/backend/src/ir/instruction.cpp
> @@ -784,6 +784,8 @@ namespace ir {
> default:
> CHECK_TYPE(this->type, allButBool);
> break;
> + case OP_MOV:
> + break;
> case OP_POW:
> case OP_COS:
> case OP_SIN:
> diff --git a/backend/src/llvm/llvm_gen_backend.cpp b/backend/src/llvm/llvm_gen_backend.cpp
> index d1d0579..23e5442 100644
> --- a/backend/src/llvm/llvm_gen_backend.cpp
> +++ b/backend/src/llvm/llvm_gen_backend.cpp
> @@ -1025,8 +1025,6 @@ namespace gbe
> Value *IV = PN->getIncomingValueForBlock(curr);
> if (!isa<UndefValue>(IV)) {
> Type *llvmType = PN->getType();
> - GBE_ASSERTM(llvmType != Type::getInt1Ty(llvmType->getContext()),
> - "TODO Boolean values cannot escape their definition basic block");
> const ir::Type type = getType(ctx, llvmType);
>
> // Emit the MOV required by the PHI function. We do it simple and do not
> diff --git a/utests/compiler_bool_cross_basic_block.cpp b/utests/compiler_bool_cross_basic_block.cpp
> index 4dd5bc7..908edc0 100644
> --- a/utests/compiler_bool_cross_basic_block.cpp
> +++ b/utests/compiler_bool_cross_basic_block.cpp
> @@ -52,4 +52,4 @@ void compiler_bool_cross_basic_block(void){
>
> }
>
> -MAKE_UTEST_FROM_FUNCTION_WITH_ISSUE(compiler_bool_cross_basic_block)
> +MAKE_UTEST_FROM_FUNCTION(compiler_bool_cross_basic_block)
> --
> 1.8.1.2
>
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list