From d0f1a94e3d4054a8aad2c76714866fecddd768bf Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 11 Dec 2024 12:49:55 -0800 Subject: [PATCH] brw/build: Prepare BROADCAST for scalar values Reviewed-by: Kenneth Graunke Part-of: --- src/intel/compiler/brw_fs_builder.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/intel/compiler/brw_fs_builder.h b/src/intel/compiler/brw_fs_builder.h index 9d5f6acd4ef..3773943c552 100644 --- a/src/intel/compiler/brw_fs_builder.h +++ b/src/intel/compiler/brw_fs_builder.h @@ -806,6 +806,22 @@ namespace brw { assert(is_uniform(index)); + /* A broadcast will always be at the full dispatch width even if the + * use of the broadcast result is smaller. If the source is_scalar, + * it may be allocated at less than the full dispatch width (e.g., + * allocated at SIMD8 with SIMD32 dispatch). The input may or may + * not be stride=0. If it is not, the generated broadcast + * + * broadcast(32) dst, value<1>, index<0> + * + * is invalid because it may read out of bounds from value. + * + * To account for this, modify the stride of an is_scalar input to be + * zero. + */ + if (value.is_scalar) + value = component(value, 0); + /* Ensure that the source of a broadcast is always register aligned. * See brw_broadcast() non-scalar case for more details. */