From bd701916cca181f9eb7b6e9306ea59a319eab29a Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 27 Oct 2024 03:21:18 +0300 Subject: [PATCH] gpu_unai: don't typedef le32_t as structs Experiments show it prevents autovectorization on some compilers, so do it in asserts build only. --- plugins/gpu_unai/gpu_unai.h | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/plugins/gpu_unai/gpu_unai.h b/plugins/gpu_unai/gpu_unai.h index 33062022..844a8fd4 100644 --- a/plugins/gpu_unai/gpu_unai.h +++ b/plugins/gpu_unai/gpu_unai.h @@ -22,6 +22,7 @@ #ifndef GPU_UNAI_H #define GPU_UNAI_H +#include #include "gpu.h" // Header shared between both standalone gpu_unai (gpu.cpp) and new @@ -62,6 +63,8 @@ typedef union { u64 raw; } gcol_t; +#ifndef NDEBUG + typedef struct { u32 v; } le32_t; @@ -70,44 +73,54 @@ typedef struct { u16 v; } le16_t; +#define LExRead(v_) (v_.v) + +#else + +typedef u32 le32_t; +typedef u16 le16_t; +#define LExRead(v) (v) + +#endif + static inline u32 le32_to_u32(le32_t le) { - return LE32TOH(le.v); + return LE32TOH(LExRead(le)); } static inline s32 le32_to_s32(le32_t le) { - return (int32_t) LE32TOH(le.v); + return (int32_t) LE32TOH(LExRead(le)); } static inline u32 le32_raw(le32_t le) { - return le.v; + return LExRead(le); } static inline le32_t u32_to_le32(u32 u) { - return (le32_t){ .v = HTOLE32(u) }; + return (le32_t){ HTOLE32(u) }; } static inline u16 le16_to_u16(le16_t le) { - return LE16TOH(le.v); + return LE16TOH(LExRead(le)); } static inline s16 le16_to_s16(le16_t le) { - return (int16_t) LE16TOH(le.v); + return (int16_t) LE16TOH(LExRead(le)); } static inline u16 le16_raw(le16_t le) { - return le.v; + return LExRead(le); } static inline le16_t u16_to_le16(u16 u) { - return (le16_t){ .v = HTOLE16(u) }; + return (le16_t){ HTOLE16(u) }; } union PtrUnion -- 2.39.5