From 0bc6bd93417179cd0c30fac40d2fd11aa29c8523 Mon Sep 17 00:00:00 2001
From: Adam Sampson <ats@offog.org>
Date: Sun, 5 Oct 2025 14:03:24 +0100
Subject: [PATCH] x86: put the memory operand first for test

Older versions of nasm allowed the operands in either order, but nasm
3.00 requires the memory operand to be first as per the spec.
---
 src/x86/filmgrain16_avx2.asm   | 4 ++--
 src/x86/filmgrain16_avx512.asm | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/x86/filmgrain16_avx2.asm b/src/x86/filmgrain16_avx2.asm
index eda603592..128d178bb 100644
--- a/src/x86/filmgrain16_avx2.asm
+++ b/src/x86/filmgrain16_avx2.asm
@@ -871,7 +871,7 @@ cglobal fgy_32x32xn_16bpc, 6, 14, 16, dst, src, stride, fg_data, w, scaling, \
     test           sbyd, sbyd
     setnz           r7b
     vpbroadcastd    m14, [base+pd_16]
-    test            r7b, [fg_dataq+FGData.overlap_flag]
+    test            [fg_dataq+FGData.overlap_flag], r7b
     jnz .vertical_overlap
 
     imul           seed, sbyd, (173 << 24) | 37
@@ -1363,7 +1363,7 @@ cglobal fguv_32x32xn_i%1_16bpc, 6, 15, 16, dst, src, stride, fg_data, w, scaling
 %endif
     vpbroadcastd    m14, [base+pd_16]
 %endif
-    test            r7b, [fg_dataq+FGData.overlap_flag]
+    test            [fg_dataq+FGData.overlap_flag], r7b
     jnz %%vertical_overlap
 
     imul           seed, sbyd, (173 << 24) | 37
diff --git a/src/x86/filmgrain16_avx512.asm b/src/x86/filmgrain16_avx512.asm
index 5cbebcef5..d6d7ac2c4 100644
--- a/src/x86/filmgrain16_avx512.asm
+++ b/src/x86/filmgrain16_avx512.asm
@@ -81,7 +81,7 @@ cglobal fgy_32x32xn_16bpc, 6, 15, 21, dst, src, stride, fg_data, w, scaling, \
     setnz           r7b
     vpbroadcastd    m12, [base+pw_27_17_17_27+r6*8+0]
     vpbroadcastd    m13, [base+pw_27_17_17_27+r6*8+4]
-    test            r7b, [fg_dataq+FGData.overlap_flag]
+    test            [fg_dataq+FGData.overlap_flag], r7b
     jnz .v_overlap
 
     imul           seed, sbyd, (173 << 24) | 37
@@ -417,7 +417,7 @@ cglobal fguv_32x32xn_i%1_16bpc, 6, 15, 22, dst, src, stride, fg_data, w, scaling
     pmaddwd         m14, m0
     pshufb          m15, m1 ; { uv_luma_mult, uv_mult }
 %endif
-    test            r7b, [fg_dataq+FGData.overlap_flag]
+    test            [fg_dataq+FGData.overlap_flag], r7b
     jnz %%v_overlap
 
     imul           seed, sbyd, (173 << 24) | 37
-- 
GitLab

