[FFmpeg-devel] [PATCH] gcc: Don't disable '-ftree-vectorize' on GCC >= 13 on major architectures (PR #20120)
Rémi Denis-Courmont
remi at remlab.net
Wed Aug 6 08:42:12 EEST 2025
Hi,
FWIW I don't really care personally but judging by the original author and their affiliation, the intent was most probably to enable this for RISC-V / RVA23.
On that platform it is *probably* safe to enable vectorisation on all GCC versions but I have not tested it. In fact, I don't have an RVA23-conformant board.
Le 5 août 2025 21:15:26 GMT+07:00, "Martin Storsjö" <code at ffmpeg.org> a écrit :
>PR #20120 opened by Martin Storsjö (mstorsjo)
>URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20120
>Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20120.patch
>
>This changes configure to stop disabling -ftree-vectorize on
>GCC versions 13 and newer, on major architectures.
>
>Background:
>- Original `-fno-tree-vectorize` was added in 2009 in commit
> 973859f5230e to avoid compiler errors.
>- Re-enabled in 2016 in commit cb8646af24bd but caused failures due
> to inline CABAC assembly issues and was disabled again in
> fd6dbc53855fb.
>- Commit 182663a58a7a in 2023 fixed the inline CABAC assembly issues.
>- Recent versions of GCC, in particular 13 and newer, seem to
> generally work reliably with respect to vectorization, although bugs
> have been observed on Loongarch.
>
>Cautiously allow the GCC default of having vectorization enabled,
>on major architectures where we expect to see enough testing. If
>further issues are observed, they should be reported and noted here in
>configure, so the workarounds can be scoped and version limited.
>
>
>From f95261fab763cae5723513c9281d073048284ed4 Mon Sep 17 00:00:00 2001
>From: Jiawei <jiawei at iscas.ac.cn>
>Date: Mon, 14 Jul 2025 19:29:57 +0800
>Subject: [PATCH] gcc: Don't disable '-ftree-vectorize' on GCC >= 13 on major
> architectures
>
>This changes configure to stop disabling -ftree-vectorize on
>GCC versions 13 and newer, on major architectures.
>
>Background:
>- Original `-fno-tree-vectorize` was added in 2009 in commit
> 973859f5230e to avoid compiler errors.
>- Re-enabled in 2016 in commit cb8646af24bd but caused failures due
> to inline CABAC assembly issues and was disabled again in
> fd6dbc53855fb.
>- Commit 182663a58a7a in 2023 fixed the inline CABAC assembly issues.
>- Recent versions of GCC, in particular 13 and newer, seem to
> generally work reliably with respect to vectorization, although bugs
> have been observed on Loongarch.
>
>Cautiously allow the GCC default of having vectorization enabled,
>on major architectures where we expect to see enough testing. If
>further issues are observed, they should be reported and noted here in
>configure, so the workarounds can be scoped and version limited.
>---
> Changelog | 1 +
> configure | 20 +++++++++++++++++++-
> 2 files changed, 20 insertions(+), 1 deletion(-)
>
>diff --git a/Changelog b/Changelog
>index 04db8e15b2..b7704604f4 100644
>--- a/Changelog
>+++ b/Changelog
>@@ -26,6 +26,7 @@ version <next>:
> - OpenHarmony hardware decoder/encoder
> - Colordetect filter
> - Add vf_scale_d3d11 filter
>+- No longer disabling GCC autovectorization, on X86, ARM and AArch64
>
>
> version 7.1:
>diff --git a/configure b/configure
>index c0a4c3c87c..760e27fd70 100755
>--- a/configure
>+++ b/configure
>@@ -7714,7 +7714,25 @@ if enabled icc; then
> disable aligned_stack
> fi
> elif enabled gcc; then
>- check_optflags -fno-tree-vectorize
>+ gcc_version=$($cc -dumpversion)
>+ major_version=${gcc_version%%.*}
>+ if [ $major_version -lt 13 ]; then
>+ # Disable tree-vectorize for GCC <13 - it has historically been buggy.
>+ check_optflags -fno-tree-vectorize
>+ else
>+ case $arch in
>+ x86|arm|aarch64)
>+ # Allow the default of having tree-vectorize enabled on well tested
>+ # architectures.
>+ ;;
>+ *)
>+ # Disable tree-vectorize on potentially less tested
>+ # architectures. Known issues:
>+ # - https://gcc.gnu.org/PR121064 on Loongarch
>+ check_optflags -fno-tree-vectorize
>+ ;;
>+ esac
>+ fi
> check_cflags -Werror=format-security
> check_cflags -Werror=implicit-function-declaration
> check_cflags -Werror=missing-prototypes
>--
>2.49.1
>
>_______________________________________________
>ffmpeg-devel mailing list
>ffmpeg-devel at ffmpeg.org
>https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>To unsubscribe, visit link above, or email
>ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
More information about the ffmpeg-devel
mailing list