arch/x86_64:Add configuration to disable vectorization optimization

With aggresive optimization enabled (-O3), ostest FPU test will fail.This is because the compiler will generate additional vector instructions between subsequent up_fpucmp() calls (loop vectorization somewhere in usleep() call), which will consequently overwrite the expected FPU context (XMM registers).The compilation option -fno-tree-vectorize can avoid this issue.

Signed-off-by: liwenxiang1 <liwenxiang1@xiaomi.com>
This commit is contained in:
liwenxiang1 2024-07-26 14:15:43 +08:00 • committed by Xiang Xiao
parent 19e34b7f6e
commit 9189800760
2 changed files with 12 additions and 4 deletions

View file

@ -51,6 +51,14 @@ ifeq ($(CONFIG_FRAME_POINTER),y)
ARCHOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls
endif
ifeq ($(CONFIG_ARCH_INTEL64_DISABLE_CET),y)
ARCHOPTIMIZATION += -fcf-protection=none
endif
ifeq ($(CONFIG_ARCH_INTEL64_DISABLE_VECTORIZE),y)
ARCHOPTIMIZATION += -fno-tree-vectorize
endif
ARCHCFLAGS += -fno-common -Wno-attributes
ARCHCXXFLAGS += -fno-common -Wno-attributes -nostdinc++
@ -58,10 +66,6 @@ ARCHCPUFLAGS = -fno-pic -mcmodel=large -fno-stack-protector -mno-red-zone -mrdrn
ARCHPICFLAGS = -fPIC
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef
ifeq ($(CONFIG_ARCH_INTEL64_DISABLE_CET),y)
ARCHOPTIMIZATION += -fcf-protection=none
endif
# We have to use a cross-development toolchain under Cygwin because the native
# Cygwin toolchains don't generate ELF binaries.

View file

@ -203,5 +203,9 @@ config ARCH_INTEL64_DISABLE_CET
It inserts the endbr64 instruction at the beginning of functions,
which may impact CPU branch prediction performance.
config ARCH_INTEL64_DISABLE_VECTORIZE
bool "Disable vectorize completely"
---help---
Disable the compiler from vectorizing code optimization during compilation
endif