Skip to content

Commit 0c90ded

Browse files
authored
Fix AVX instructions used on CPUs that don't support them (#1935)
* Fix AVX instructions used on CPUs that don't support them It's supposed to check all bits are enabled, not just one of them. This causes a crash using OpenColorIO on older CPUs. Thanks to Ray Molenkamp for help tracking this down. Signed-off-by: Brecht Van Lommel <brecht@blender.org> * Fix another case pointed out in review Signed-off-by: Brecht Van Lommel <brecht@blender.org> --------- Signed-off-by: Brecht Van Lommel <brecht@blender.org>
1 parent aadf595 commit 0c90ded

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/OpenColorIO/CPUInfo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ CPUInfo::CPUInfo()
107107
flags |= X86_CPU_FLAG_SSE42;
108108

109109
/* Check OSXSAVE and AVX bits */
110-
if (info.reg.ecx & 0x18000000)
110+
if ((info.reg.ecx & 0x18000000) == 0x18000000)
111111
{
112112
xcr = xgetbv();
113-
if(xcr & 0x6) {
113+
if((xcr & 0x6) == 0x6) {
114114
flags |= X86_CPU_FLAG_AVX;
115115

116116
if(info.reg.ecx & 0x20000000) {
@@ -129,7 +129,7 @@ CPUInfo::CPUInfo()
129129

130130
/* OPMASK/ZMM state */
131131
if ((xcr & 0xe0) == 0xe0) {
132-
if ((flags & X86_CPU_FLAG_AVX2) && (info.reg.ebx & 0xd0030000))
132+
if ((flags & X86_CPU_FLAG_AVX2) && ((info.reg.ebx & 0xd0030000) == 0xd0030000))
133133
flags |= X86_CPU_FLAG_AVX512;
134134
}
135135
}

0 commit comments

Comments
 (0)