Skip to content

Commit

Permalink
arch/x86_64:Add configuration to disable vectorization optimization
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
xianglyc authored and xiaoxiang781216 committed Oct 11, 2024
1 parent 19e34b7 commit 9189800
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 8 additions & 4 deletions arch/x86_64/src/common/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,21 @@ 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++

ARCHCPUFLAGS = -fno-pic -mcmodel=large -fno-stack-protector -mno-red-zone -mrdrnd
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.

Expand Down
4 changes: 4 additions & 0 deletions arch/x86_64/src/intel64/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 9189800

Please sign in to comment.