Commit df4617b
Check XCR0 register before using AVX2 / AVX512 instructions
Along with checking CPUID, it's necessary to look in the XCR0
register to check that AVX, AVX2 and AVX512 instructions can
be used. (The operating system can write to this register to
selectively enable or disable these features). See the Intel 64
and IA-32 Architectures Software Developer’s Manual Vol. 1
sections 13.2 and 13.3 for details.
XCR0 is read using the XGETBV instruction. While there is an
intrinsic for this, using it requires specific compiler options
that we may not want to use for htscodecs/rANS_static4x16pr.c
compilation. The intrinsic also didn't work until gcc 9.
As some binutils still in use may not know about XGETBV, the
instruction is written as a byte stream in the inline assembly.1 parent 4b2c1de commit df4617b
1 file changed
+29
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
864 | 864 | | |
865 | 865 | | |
866 | 866 | | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
867 | 870 | | |
868 | 871 | | |
869 | 872 | | |
| |||
880 | 883 | | |
881 | 884 | | |
882 | 885 | | |
883 | | - | |
884 | | - | |
885 | | - | |
886 | 886 | | |
887 | 887 | | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
888 | 908 | | |
889 | 909 | | |
890 | | - | |
891 | | - | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
892 | 913 | | |
893 | 914 | | |
894 | 915 | | |
895 | 916 | | |
896 | 917 | | |
897 | | - | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
898 | 921 | | |
899 | 922 | | |
900 | 923 | | |
| |||
0 commit comments