From f11bb5a06ec93d4d79e5b97bfc646c85cd2c0bf8 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Fri, 24 Feb 2023 12:39:54 -0800 Subject: [PATCH] Add a var_types_classification for simd (#82616) * Add a var_types_classification for simd * Ensure TYP_SIMD are actually marked VTF_VEC --- src/coreclr/jit/typelist.h | 8 ++++---- src/coreclr/jit/vartype.h | 25 ++++++------------------- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/src/coreclr/jit/typelist.h b/src/coreclr/jit/typelist.h index f7af257322506..ae804f591dedf 100644 --- a/src/coreclr/jit/typelist.h +++ b/src/coreclr/jit/typelist.h @@ -58,10 +58,10 @@ DEF_TP(LCLBLK ,"lclBlk" , TYP_LCLBLK, TI_ERROR, 0, 0, 0, 1, 4, VTF_ANY) / #ifdef FEATURE_SIMD // Amd64: The size and alignment of SIMD vector varies at JIT time based on whether target arch supports AVX or SSE2. -DEF_TP(SIMD8 ,"simd8" , TYP_SIMD8, TI_STRUCT, 8, 8, 8, 2, 8, VTF_S) -DEF_TP(SIMD12 ,"simd12" , TYP_SIMD12, TI_STRUCT,12,16, 16, 4,16, VTF_S) -DEF_TP(SIMD16 ,"simd16" , TYP_SIMD16, TI_STRUCT,16,16, 16, 4,16, VTF_S) -DEF_TP(SIMD32 ,"simd32" , TYP_SIMD32, TI_STRUCT,32,32, 32, 8,16, VTF_S) +DEF_TP(SIMD8 ,"simd8" , TYP_SIMD8, TI_STRUCT, 8, 8, 8, 2, 8, VTF_S|VTF_VEC) +DEF_TP(SIMD12 ,"simd12" , TYP_SIMD12, TI_STRUCT,12,16, 16, 4,16, VTF_S|VTF_VEC) +DEF_TP(SIMD16 ,"simd16" , TYP_SIMD16, TI_STRUCT,16,16, 16, 4,16, VTF_S|VTF_VEC) +DEF_TP(SIMD32 ,"simd32" , TYP_SIMD32, TI_STRUCT,32,32, 32, 8,16, VTF_S|VTF_VEC) #endif // FEATURE_SIMD DEF_TP(UNKNOWN ,"unknown" ,TYP_UNKNOWN, TI_ERROR, 0, 0, 0, 0, 0, VTF_ANY) diff --git a/src/coreclr/jit/vartype.h b/src/coreclr/jit/vartype.h index 33c411032d330..a51dbff3b82ac 100644 --- a/src/coreclr/jit/vartype.h +++ b/src/coreclr/jit/vartype.h @@ -17,6 +17,7 @@ enum var_types_classification VTF_BYR = 0x0010, // type is Byref VTF_I = 0x0020, // is machine sized VTF_S = 0x0040, // is a struct type + VTF_VEC = 0x0080, // is a vector type }; #include "vartypesdef.h" @@ -61,30 +62,16 @@ inline var_types TypeGet(var_types v) return v; } -#ifdef FEATURE_SIMD -template -inline bool varTypeIsSIMD(T vt) -{ - switch (TypeGet(vt)) - { - case TYP_SIMD8: - case TYP_SIMD12: - case TYP_SIMD16: - case TYP_SIMD32: - return true; - default: - return false; - } -} -#else // FEATURE_SIMD - -// Always return false if FEATURE_SIMD is not enabled template inline bool varTypeIsSIMD(T vt) { +#ifdef FEATURE_SIMD + return ((varTypeClassification[TypeGet(vt)] & VTF_VEC) != 0); +#else + // Always return false if FEATURE_SIMD is not enabled return false; -} #endif // !FEATURE_SIMD +} template inline bool varTypeIsIntegral(T vt)