Skip to content

Commit 9189800

Browse files
xianglycxiaoxiang781216
authored andcommitted
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 <[email protected]>
1 parent 19e34b7 commit 9189800

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

arch/x86_64/src/common/Toolchain.defs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,21 @@ ifeq ($(CONFIG_FRAME_POINTER),y)
5151
ARCHOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls
5252
endif
5353

54+
ifeq ($(CONFIG_ARCH_INTEL64_DISABLE_CET),y)
55+
ARCHOPTIMIZATION += -fcf-protection=none
56+
endif
57+
58+
ifeq ($(CONFIG_ARCH_INTEL64_DISABLE_VECTORIZE),y)
59+
ARCHOPTIMIZATION += -fno-tree-vectorize
60+
endif
61+
5462
ARCHCFLAGS += -fno-common -Wno-attributes
5563
ARCHCXXFLAGS += -fno-common -Wno-attributes -nostdinc++
5664

5765
ARCHCPUFLAGS = -fno-pic -mcmodel=large -fno-stack-protector -mno-red-zone -mrdrnd
5866
ARCHPICFLAGS = -fPIC
5967
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef
6068

61-
ifeq ($(CONFIG_ARCH_INTEL64_DISABLE_CET),y)
62-
ARCHOPTIMIZATION += -fcf-protection=none
63-
endif
64-
6569
# We have to use a cross-development toolchain under Cygwin because the native
6670
# Cygwin toolchains don't generate ELF binaries.
6771

arch/x86_64/src/intel64/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,5 +203,9 @@ config ARCH_INTEL64_DISABLE_CET
203203
It inserts the endbr64 instruction at the beginning of functions,
204204
which may impact CPU branch prediction performance.
205205

206+
config ARCH_INTEL64_DISABLE_VECTORIZE
207+
bool "Disable vectorize completely"
208+
---help---
209+
Disable the compiler from vectorizing code optimization during compilation
206210

207211
endif

0 commit comments

Comments
 (0)