samples/subsys/audio/sof: use -fstrict-overflow for SOF

Align compiler flags of SOF Zephyr build with the build SOF XTOS
and use -fstrict-overflow.

With -fno-strict-overflow, some versions of XCC compiler (e.g. xt-xcc
12.0.8) always emit a "bltu" instruction to check for overflow in loops
like:

  unsigned int n;
  for(n = 0; n < 1024; n++)
	do_arithmetic();

With "-fno-strict-overflow", you'll have:
  18:   068076                  loop    a0, 22 <dummy_dspload+0x22>
  1b:   445a                    add.n   a4, a4, a5
  1d:   551b                    addi.n  a5, a5, 1
  1f:   023657                  bltu    a6, a5, 25 <dummy_dspload+0x25>
  22:   fffc86                  j       18 <dummy_dspload+0x18>

With "-fstrict-overflow":
  16:   038476                  loop    a4, 1d <dummy_dspload+0x1d>
  19:   223a                    add.n   a2, a2, a3
  1b:   331b                    addi.n  a3, a3, 1

As this is a common pattern in audio DSP code, change the default
for SOF builds to -fstrict-overflow.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
This commit is contained in:
Kai Vehmanen 2022-01-03 20:32:18 +02:00 committed by Anas Nashif
parent 212347f94d
commit 60325019aa

View file

@ -8,6 +8,10 @@ CONFIG_DEBUG_MEMORY_USAGE_SCAN=n
# Ensure -O2 (or similar) is used for optimization
CONFIG_SPEED_OPTIMIZATIONS=y
# Zephyr top-level default of -fno-strict-overflow is
# not a good fit for audio DSP code
CONFIG_COMPILER_OPT="-fstrict-overflow"
CONFIG_SCHED_DEADLINE=y
CONFIG_SCHED_CPU_MASK=y
CONFIG_SMP_BOOT_DELAY=y