From 4f0c852a4ed4c08839dbe3c63ea57f21752de14e Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 2 Jan 2025 00:30:36 -0800 Subject: [PATCH] brw: Skip unnecessary work for trivial emit_uniformize of IMMs If we pass an immediate, just trivially return that immediate. This preserves the property that if x was an IMM, emit_uniformize(x) will also be an IMM, without the need for optimizations to eliminate unnecessary operations. That way, you can call emit_uniformize() on a value and still check whether it's constant afterwards. Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/compiler/brw_fs_builder.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/intel/compiler/brw_fs_builder.h b/src/intel/compiler/brw_fs_builder.h index 3773943c552..638f1ac9145 100644 --- a/src/intel/compiler/brw_fs_builder.h +++ b/src/intel/compiler/brw_fs_builder.h @@ -382,6 +382,10 @@ namespace brw { brw_reg emit_uniformize(const brw_reg &src) const { + /* Trivial: skip unnecessary work and retain IMM */ + if (src.file == IMM) + return src; + /* FIXME: We use a vector chan_index and dst to allow constant and * copy propagration to move result all the way into the consuming * instruction (typically a surface index or sampler index for a