[Mesa-dev] [PATCH 25/25] i965: Optimize reading the destination type

Matt Turner mattst88 at gmail.com
Fri Aug 4 17:31:57 UTC 2017


brw_hw_type_to_reg_type() needs to know only whether the file is
BRW_IMMEDIATE_VALUE or not, which is not a valid file for the
destination. gcc and clang will evaluate __builtin_strcmp() at compile
time, so we can use it to pass a constant file for the destination.

   text	   data	    bss	    dec	    hex	filename
7816214	 346248	 420496	8582958	 82f72e	i965_dri.so before
7816070	 346248	 420496	8582814	 82f69e	i965_dri.so after
---
 src/intel/compiler/brw_inst.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/intel/compiler/brw_inst.h b/src/intel/compiler/brw_inst.h
index eacc0a024a..e9dad38f69 100644
--- a/src/intel/compiler/brw_inst.h
+++ b/src/intel/compiler/brw_inst.h
@@ -669,7 +669,9 @@ static inline enum brw_reg_type                                               \
 brw_inst_##reg##_type(const struct gen_device_info *devinfo,                  \
                       const brw_inst *inst)                                   \
 {                                                                             \
-   unsigned file = brw_inst_##reg##_reg_file(devinfo, inst);                  \
+   unsigned file = __builtin_strcmp("dst", #reg) == 0 ?                       \
+                   BRW_GENERAL_REGISTER_FILE :                                \
+                   brw_inst_##reg##_reg_file(devinfo, inst);                  \
    unsigned hw_type = brw_inst_##reg##_reg_hw_type(devinfo, inst);            \
    return brw_hw_type_to_reg_type(devinfo, (enum brw_reg_file)file, hw_type); \
 }
-- 
2.13.0



More information about the mesa-dev mailing list