You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As with the Intel and Arm CRC instructions, compiler intrinsics for
them must be supported by the compiler. In contrast, no runtime check
is needed. Aligned memory access is faster, so use the Arm coding as
a model.
YANG Xudong
Discussion: https://postgr.es/m/b522a0c5-e3b2-99cc-6387-58134fb88cbe%40ymatrix.cn
if test x"$pgac_cv_loongarch_crc32c_intrinsics" = x"yes"; then
18087
+
pgac_loongarch_crc32c_intrinsics=yes
18088
+
fi
18089
+
18090
+
18050
18091
18051
18092
18052
18093
# Select CRC-32C implementation.
@@ -18063,9 +18104,12 @@ fi
18063
18104
# we're not targeting such a processor, but can nevertheless produce code that
18064
18105
# uses the CRC instructions, compile both, and select at runtime.
18065
18106
#
18066
-
# You can override this logic by setting the appropriate USE_*_CRC32 flag to 1
18107
+
# You can skip the runtime check by setting the appropriate USE_*_CRC32 flag to 1
18067
18108
# in the template or configure command line.
18068
-
if test x"$USE_SLICING_BY_8_CRC32C" = x"" && test x"$USE_SSE42_CRC32C" = x"" && test x"$USE_SSE42_CRC32C_WITH_RUNTIME_CHECK" = x"" && test x"$USE_ARMV8_CRC32C" = x"" && test x"$USE_ARMV8_CRC32C_WITH_RUNTIME_CHECK" = x""; then
18109
+
#
18110
+
# If we are targeting a LoongArch processor, CRC instructions are
18111
+
# always available (at least on 64 bit), so no runtime check is needed.
18112
+
if test x"$USE_SLICING_BY_8_CRC32C" = x"" && test x"$USE_SSE42_CRC32C" = x"" && test x"$USE_SSE42_CRC32C_WITH_RUNTIME_CHECK" = x"" && test x"$USE_ARMV8_CRC32C" = x"" && test x"$USE_ARMV8_CRC32C_WITH_RUNTIME_CHECK" = x"" && test x"$USE_LOONGARCH_CRC32C" = x""; then
18069
18113
# Use Intel SSE 4.2 if available.
18070
18114
if test x"$pgac_sse42_crc32_intrinsics" = x"yes" && test x"$SSE4_2_TARGETED" = x"1" ; then
18071
18115
USE_SSE42_CRC32C=1
@@ -18083,10 +18127,15 @@ if test x"$USE_SLICING_BY_8_CRC32C" = x"" && test x"$USE_SSE42_CRC32C" = x"" &&
18083
18127
if test x"$pgac_armv8_crc32c_intrinsics" = x"yes"; then
18084
18128
USE_ARMV8_CRC32C_WITH_RUNTIME_CHECK=1
18085
18129
else
18086
-
# fall back to slicing-by-8 algorithm, which doesn't require any
18087
-
# special CPU support.
18088
-
USE_SLICING_BY_8_CRC32C=1
18089
-
fi
18130
+
# LoongArch CRCC instructions.
18131
+
if test x"$pgac_loongarch_crc32c_intrinsics" = x"yes"; then
18132
+
USE_LOONGARCH_CRC32C=1
18133
+
else
18134
+
# fall back to slicing-by-8 algorithm, which doesn't require any
# Check for LoongArch CRC intrinsics to do CRC calculations.
2103
+
#
2104
+
# Check if __builtin_loongarch_crcc_* intrinsics can be used
2105
+
# with the default compiler flags.
2106
+
PGAC_LOONGARCH_CRC32C_INTRINSICS()
2107
+
2102
2108
AC_SUBST(CFLAGS_CRC)
2103
2109
2104
2110
# Select CRC-32C implementation.
@@ -2115,9 +2121,12 @@ AC_SUBST(CFLAGS_CRC)
2115
2121
# we're not targeting such a processor, but can nevertheless produce code that
2116
2122
# uses the CRC instructions, compile both, and select at runtime.
2117
2123
#
2118
-
# You can override this logic by setting the appropriate USE_*_CRC32 flag to 1
2124
+
# You can skip the runtime check by setting the appropriate USE_*_CRC32 flag to 1
2119
2125
# in the template or configure command line.
2120
-
if test x"$USE_SLICING_BY_8_CRC32C" = x"" && test x"$USE_SSE42_CRC32C" = x"" && test x"$USE_SSE42_CRC32C_WITH_RUNTIME_CHECK" = x"" && test x"$USE_ARMV8_CRC32C" = x"" && test x"$USE_ARMV8_CRC32C_WITH_RUNTIME_CHECK" = x""; then
2126
+
#
2127
+
# If we are targeting a LoongArch processor, CRC instructions are
2128
+
# always available (at least on 64 bit), so no runtime check is needed.
2129
+
if test x"$USE_SLICING_BY_8_CRC32C" = x"" && test x"$USE_SSE42_CRC32C" = x"" && test x"$USE_SSE42_CRC32C_WITH_RUNTIME_CHECK" = x"" && test x"$USE_ARMV8_CRC32C" = x"" && test x"$USE_ARMV8_CRC32C_WITH_RUNTIME_CHECK" = x"" && test x"$USE_LOONGARCH_CRC32C" = x""; then
2121
2130
# Use Intel SSE 4.2 if available.
2122
2131
if test x"$pgac_sse42_crc32_intrinsics" = x"yes" && test x"$SSE4_2_TARGETED" = x"1" ; then
2123
2132
USE_SSE42_CRC32C=1
@@ -2135,10 +2144,15 @@ if test x"$USE_SLICING_BY_8_CRC32C" = x"" && test x"$USE_SSE42_CRC32C" = x"" &&
2135
2144
if test x"$pgac_armv8_crc32c_intrinsics" = x"yes"; then
2136
2145
USE_ARMV8_CRC32C_WITH_RUNTIME_CHECK=1
2137
2146
else
2138
-
# fall back to slicing-by-8 algorithm, which doesn't require any
2139
-
# special CPU support.
2140
-
USE_SLICING_BY_8_CRC32C=1
2141
-
fi
2147
+
# LoongArch CRCC instructions.
2148
+
if test x"$pgac_loongarch_crc32c_intrinsics" = x"yes"; then
2149
+
USE_LOONGARCH_CRC32C=1
2150
+
else
2151
+
# fall back to slicing-by-8 algorithm, which doesn't require any
/* return computed value, to prevent the above being optimized away */
2081
+
return crc == 0;
2082
+
}
2083
+
'''
2084
+
2085
+
if cc.links(prog, name: '__builtin_loongarch_crcc_w_b_w, __builtin_loongarch_crcc_w_h_w, __builtin_loongarch_crcc_w_w_w, and __builtin_loongarch_crcc_w_d_w',
0 commit comments