Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 1b65a4f

Browse files
committed
Bug 1520760 - Fix AVX2 detection to ensure we have all required CPU parameters. r=jrmuizel
Differential Revision: https://phabricator.services.mozilla.com/D16994
1 parent 8fba17b commit 1b65a4f

4 files changed

Lines changed: 40 additions & 3 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Bug 1520760 - Fix AVX2 detection to ensure we have all required CPU parameters.
2+
3+
diff --git simd/i386/jsimdcpu.asm simd/i386/jsimdcpu.asm
4+
--- simd/i386/jsimdcpu.asm
5+
+++ simd/i386/jsimdcpu.asm
6+
@@ -87,8 +87,10 @@ EXTN(jpeg_simd_cpu_support):
7+
mov eax, 1
8+
xor ecx, ecx
9+
cpuid
10+
- test ecx, 1<<27
11+
+ test ecx, 1<<26
12+
jz short .no_avx2 ; O/S does not support XSAVE
13+
+ test ecx, 1<<27
14+
+ jz short .no_avx2 ; O/S does not support OSXSAVE
15+
test ecx, 1<<28
16+
jz short .no_avx2 ; CPU does not support AVX2
17+
18+
diff --git simd/x86_64/jsimdcpu.asm simd/x86_64/jsimdcpu.asm
19+
--- simd/x86_64/jsimdcpu.asm
20+
+++ simd/x86_64/jsimdcpu.asm
21+
@@ -53,8 +53,10 @@ EXTN(jpeg_simd_cpu_support):
22+
mov rax, 1
23+
xor rcx, rcx
24+
cpuid
25+
- test rcx, 1<<27
26+
+ test rcx, 1<<26
27+
jz short .return ; O/S does not support XSAVE
28+
+ test rcx, 1<<27
29+
+ jz short .return ; O/S does not support OSXSAVE
30+
test rcx, 1<<28
31+
jz short .return ; CPU does not support AVX2
32+

media/libjpeg/simd/i386/jsimdcpu.asm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,10 @@ EXTN(jpeg_simd_cpu_support):
8787
mov eax, 1
8888
xor ecx, ecx
8989
cpuid
90-
test ecx, 1<<27
90+
test ecx, 1<<26
9191
jz short .no_avx2 ; O/S does not support XSAVE
92+
test ecx, 1<<27
93+
jz short .no_avx2 ; O/S does not support OSXSAVE
9294
test ecx, 1<<28
9395
jz short .no_avx2 ; CPU does not support AVX2
9496

media/libjpeg/simd/x86_64/jsimdcpu.asm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ EXTN(jpeg_simd_cpu_support):
5353
mov rax, 1
5454
xor rcx, rcx
5555
cpuid
56-
test rcx, 1<<27
56+
test rcx, 1<<26
5757
jz short .return ; O/S does not support XSAVE
58+
test rcx, 1<<27
59+
jz short .return ; O/S does not support OSXSAVE
5860
test rcx, 1<<28
5961
jz short .return ; CPU does not support AVX2
6062

media/update-libjpeg.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ tag=${2-HEAD}
1919
cd $srcdir/libjpeg
2020
cp win/jsimdcfg.inc simd/
2121

22-
revert_files="1050342.diff assembly-tables.diff externalize-table.diff jconfig.h jconfigint.h jpeg_nbits_table.c moz.build MOZCHANGES mozilla.diff simd/jsimdcfg.inc"
22+
revert_files="1050342.diff assembly-tables.diff externalize-table.diff 1520760-avx2-detection.diff jconfig.h jconfigint.h jpeg_nbits_table.c moz.build MOZCHANGES mozilla.diff simd/jsimdcfg.inc"
2323
if test -d ${topsrcdir}/.hg; then
2424
hg revert --no-backup $revert_files
2525
elif test -d ${topsrcdir}/.git; then
@@ -30,3 +30,4 @@ patch -p0 -i mozilla.diff
3030
patch -p0 -i 1050342.diff
3131
patch -p3 -i externalize-table.diff
3232
patch -p3 -i assembly-tables.diff
33+
patch -p0 -i 1520760-avx2-detection.diff

0 commit comments

Comments
 (0)