x86: Disable AVX Fast Unaligned Load on Hygon 1/2/3

Message ID 20251021055302.75139-1-litenglong@kylinos.cn (mailing list archive)
State New
Headers
Series x86: Disable AVX Fast Unaligned Load on Hygon 1/2/3 |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
redhat-pt-bot/TryBot-32bit success Build for i686
redhat-pt-bot/TryBot-still_applies warning Patch no longer applies to master

Commit Message

litenglong Oct. 21, 2025, 5:53 a.m. UTC
  - Performance testing revealed significant memcpy performance degradation
  when bit_arch_AVX_Fast_Unaligned_Load is enabled on Hygon 3.
- Hygon confirmed AVX performance issues in certain memory functions.
- Glibc benchmarks show SSE outperforms AVX for
  memcpy/memmove/memset/strcmp/strcpy/strlen and so on.
- Hardware differences primarily in floating-point operations don't justify
  AVX usage for memory operations.

Reviewed-by: gaoxiang <gaoxiang@kylinos.cn>
Signed-off-by: litenglong <litenglong@kylinos.cn>
---
 sysdeps/x86/cpu-features.c | 5 +++++
 1 file changed, 5 insertions(+)
  

Patch

diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
index b67ef541dd..286cbfb1e2 100644
--- a/sysdeps/x86/cpu-features.c
+++ b/sysdeps/x86/cpu-features.c
@@ -1123,6 +1123,11 @@  disable_tsx:
        hardware.  */
       cpu_features->preferred[index_arch_Avoid_Non_Temporal_Memset]
 	    &= ~bit_arch_Avoid_Non_Temporal_Memset;
+      if (model < 0x4) {
+        /*  Unaligned AVX loads are slower.  */
+        cpu_features->preferred[index_arch_AVX_Fast_Unaligned_Load]
+		  &= ~bit_arch_AVX_Fast_Unaligned_Load;
+      }
     }
   else
     {