From e0533ebf16edcb8b9f0687d3155417e6c1c53d35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20=C5=9Alusarz?= Date: Tue, 24 Aug 2021 10:50:42 +0200 Subject: [PATCH] intel/compiler: INT DIV function does not support source modifiers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BSpec says that for all generations. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5281 CC: mesa-stable Signed-off-by: Marcin Ĺšlusarz Reviewed-by: Lionel Landwerlin Reviewed-by: Sagar Ghuge Part-of: --- src/intel/compiler/brw_eu_emit.c | 7 +++++++ src/intel/compiler/brw_eu_validate.c | 23 +++++++++++++++++++++++ src/intel/compiler/brw_shader.cpp | 2 ++ 3 files changed, 32 insertions(+) diff --git a/src/intel/compiler/brw_eu_emit.c b/src/intel/compiler/brw_eu_emit.c index 2108cf6b8d7..ad276e60e60 100644 --- a/src/intel/compiler/brw_eu_emit.c +++ b/src/intel/compiler/brw_eu_emit.c @@ -2104,6 +2104,13 @@ void gfx6_math(struct brw_codegen *p, assert(src1.type != BRW_REGISTER_TYPE_F); assert(src1.file == BRW_GENERAL_REGISTER_FILE || (devinfo->ver >= 8 && src1.file == BRW_IMMEDIATE_VALUE)); + /* From BSpec 6647/47428 "[Instruction] Extended Math Function": + * INT DIV function does not support source modifiers. + */ + assert(!src0.negate); + assert(!src0.abs); + assert(!src1.negate); + assert(!src1.abs); } else { assert(src0.type == BRW_REGISTER_TYPE_F || (src0.type == BRW_REGISTER_TYPE_HF && devinfo->ver >= 9)); diff --git a/src/intel/compiler/brw_eu_validate.c b/src/intel/compiler/brw_eu_validate.c index 0e4ab19bf5c..68d41e3e661 100644 --- a/src/intel/compiler/brw_eu_validate.c +++ b/src/intel/compiler/brw_eu_validate.c @@ -2025,6 +2025,29 @@ instruction_restrictions(const struct intel_device_info *devinfo, } } + if (brw_inst_opcode(devinfo, inst) == BRW_OPCODE_MATH) { + unsigned math_function = brw_inst_math_function(devinfo, inst); + switch (math_function) { + case BRW_MATH_FUNCTION_INT_DIV_QUOTIENT_AND_REMAINDER: + case BRW_MATH_FUNCTION_INT_DIV_QUOTIENT: + case BRW_MATH_FUNCTION_INT_DIV_REMAINDER: { + /* Page 442 of the Broadwell PRM Volume 2a "Extended Math Function" says: + * INT DIV function does not support source modifiers. + * Bspec 6647 extends it back to Ivy Bridge. + */ + bool src0_valid = !brw_inst_src0_negate(devinfo, inst) && + !brw_inst_src0_abs(devinfo, inst); + bool src1_valid = !brw_inst_src1_negate(devinfo, inst) && + !brw_inst_src1_abs(devinfo, inst); + ERROR_IF(!src0_valid || !src1_valid, + "INT DIV function does not support source modifiers."); + break; + } + default: + break; + } + } + if (brw_inst_opcode(devinfo, inst) == BRW_OPCODE_DP4A) { /* Page 396 (page 412 of the PDF) of the DG1 PRM volume 2a says: * diff --git a/src/intel/compiler/brw_shader.cpp b/src/intel/compiler/brw_shader.cpp index 792b0572493..e0b2b167060 100644 --- a/src/intel/compiler/brw_shader.cpp +++ b/src/intel/compiler/brw_shader.cpp @@ -974,6 +974,8 @@ backend_instruction::can_do_source_mods() const case SHADER_OPCODE_CLUSTER_BROADCAST: case SHADER_OPCODE_MOV_INDIRECT: case SHADER_OPCODE_SHUFFLE: + case SHADER_OPCODE_INT_QUOTIENT: + case SHADER_OPCODE_INT_REMAINDER: return false; default: return true;