* [FFmpeg-devel] [PATCH v6] gcc: Don't disable '-ftree-vectorize' if gcc version is 13 or newer
@ 2025-06-16 8:11 Martin Storsjö
2025-06-16 8:26 ` Martin Storsjö
0 siblings, 1 reply; 5+ messages in thread
From: Martin Storsjö @ 2025-06-16 8:11 UTC (permalink / raw)
To: ffmpeg-devel
From: Jiawei <jiawei@iscas.ac.cn>
This patch modifies the FFmpeg build system to allow GCC to use the
`-ftree-vectorize` flag when the compiler version is 13 or newer.
Enabling this flag can improve performance through better loop analysis
and auto-vectorization (SIMD) opportunities in modern GCC versions.
The explicit `-fno-tree-vectorize` flag was originally added in commit
973859f5230e (2009). A previous attempt to enable `-ftree-vectorize`
was made in commit cb8646af24bd (2016), but it was reverted in
fd6dbc53855f. The reason for the revert was that the inline x86 CABAC
assembly code caused compiler errors - the compiler would run out of
available registers during vectorization, making it unable to compile
some functions. There were also reports of GCC hitting internal
compiler errors, and miscompilations on x86_64.
In commit 182663a58a7a (2023), the problematic CABAC function was made
non-inline. This significantly reduces the risk of register exhaustion
caused by inlining large assembly blocks, making the vectorizer safer
to enable for other functions.
Given improvements in GCC's vectorizer and the mitigation of the
original issue, we now re-enable `-ftree-vectorize` for GCC version 13
and above.
Signed-off-by: Jiawei <jiawei@iscas.ac.cn>
---
Reposting as iterations v3-v5 by Jiawei haven't made it to the
mailing list.
For future reference; the issues with the CABAC assembly is
easily reproducible with current GCC versions too; build a version
before 182663a58a7a (possibly backport
effadce6c756247ea8bae32dc13bb3e6f464f0eb and
f01fdedb69e4accb1d1555106d8f682ff1f1ddc7), configure a build
for x86_32 with --cpu=haswell, and it hits errors like this:
src/libavcodec/x86/cabac.h:199:5: error: ‘asm’ operand has impossible constraints
The last time there were also reports of miscompilations,
this were mentioned on the mailing list in
https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2016-May/193915.html
and
https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2016-May/193977.html.
If we apply this, let's hope that GCC has improved since last time;
this is limited to be applied on only GCC 13 and newer (but for
all architectures; in particular on aarch64 it is has been seen to
be generally beneficial in e.g. dav1d).
Also, note that this it not us explicitly opting in to an experimental
feature, but this is a default feature in GCC that we've explicitly
opted out from so far.
---
configure | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/configure b/configure
index 534b443f7d..117893ee93 100755
--- a/configure
+++ b/configure
@@ -7673,7 +7673,11 @@ 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
+ check_optflags -fno-tree-vectorize
+ fi
check_cflags -Werror=format-security
check_cflags -Werror=implicit-function-declaration
check_cflags -Werror=missing-prototypes
--
2.39.5 (Apple Git-154)
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [FFmpeg-devel] [PATCH v6] gcc: Don't disable '-ftree-vectorize' if gcc version is 13 or newer
2025-06-16 8:11 [FFmpeg-devel] [PATCH v6] gcc: Don't disable '-ftree-vectorize' if gcc version is 13 or newer Martin Storsjö
@ 2025-06-16 8:26 ` Martin Storsjö
2025-06-16 8:28 ` Reto Kromer via ffmpeg-devel
[not found] ` <0775c411-ecdc-4198-9ff1-dba4eafb3613@mail.infomaniak.com>
0 siblings, 2 replies; 5+ messages in thread
From: Martin Storsjö @ 2025-06-16 8:26 UTC (permalink / raw)
To: ffmpeg-devel
On Mon, 16 Jun 2025, Martin Storsjö wrote:
> From: Jiawei <jiawei@iscas.ac.cn>
>
> This patch modifies the FFmpeg build system to allow GCC to use the
> `-ftree-vectorize` flag when the compiler version is 13 or newer.
> Enabling this flag can improve performance through better loop analysis
> and auto-vectorization (SIMD) opportunities in modern GCC versions.
>
> The explicit `-fno-tree-vectorize` flag was originally added in commit
> 973859f5230e (2009). A previous attempt to enable `-ftree-vectorize`
> was made in commit cb8646af24bd (2016), but it was reverted in
> fd6dbc53855f. The reason for the revert was that the inline x86 CABAC
> assembly code caused compiler errors - the compiler would run out of
> available registers during vectorization, making it unable to compile
> some functions. There were also reports of GCC hitting internal
> compiler errors, and miscompilations on x86_64.
>
> In commit 182663a58a7a (2023), the problematic CABAC function was made
> non-inline. This significantly reduces the risk of register exhaustion
> caused by inlining large assembly blocks, making the vectorizer safer
> to enable for other functions.
>
> Given improvements in GCC's vectorizer and the mitigation of the
> original issue, we now re-enable `-ftree-vectorize` for GCC version 13
> and above.
>
> Signed-off-by: Jiawei <jiawei@iscas.ac.cn>
> ---
> Reposting as iterations v3-v5 by Jiawei haven't made it to the
> mailing list.
>
> For future reference; the issues with the CABAC assembly is
> easily reproducible with current GCC versions too; build a version
> before 182663a58a7a (possibly backport
> effadce6c756247ea8bae32dc13bb3e6f464f0eb and
> f01fdedb69e4accb1d1555106d8f682ff1f1ddc7), configure a build
> for x86_32 with --cpu=haswell, and it hits errors like this:
>
> src/libavcodec/x86/cabac.h:199:5: error: ‘asm’ operand has impossible constraints
>
> The last time there were also reports of miscompilations,
> this were mentioned on the mailing list in
> https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2016-May/193915.html
> and
> https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2016-May/193977.html.
>
> If we apply this, let's hope that GCC has improved since last time;
> this is limited to be applied on only GCC 13 and newer (but for
> all architectures; in particular on aarch64 it is has been seen to
> be generally beneficial in e.g. dav1d).
>
> Also, note that this it not us explicitly opting in to an experimental
> feature, but this is a default feature in GCC that we've explicitly
> opted out from so far.
> ---
> configure | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/configure b/configure
> index 534b443f7d..117893ee93 100755
> --- a/configure
> +++ b/configure
> @@ -7673,7 +7673,11 @@ 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
> + check_optflags -fno-tree-vectorize
> + fi
> check_cflags -Werror=format-security
> check_cflags -Werror=implicit-function-declaration
> check_cflags -Werror=missing-prototypes
> --
> 2.39.5 (Apple Git-154)
The loongarch64 instance on patchwork does seem to be miscompiling
something after this change, see
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20250616081107.57114-1-martin@martin.st/
and in particular https://patchwork.ffmpeg.org/check/125495/.
Not sure if the best way is to explicitly exclude known problematic
architectures, or just do this for major architectures like x86 (maybe
even exclude x86_32? or then again maybe the CABAC assembly was the only
issue there), arm and aarch64 (maybe riscv)?
// Martin
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [FFmpeg-devel] [PATCH v6] gcc: Don't disable '-ftree-vectorize' if gcc version is 13 or newer
2025-06-16 8:26 ` Martin Storsjö
@ 2025-06-16 8:28 ` Reto Kromer via ffmpeg-devel
[not found] ` <0775c411-ecdc-4198-9ff1-dba4eafb3613@mail.infomaniak.com>
1 sibling, 0 replies; 5+ messages in thread
From: Reto Kromer via ffmpeg-devel @ 2025-06-16 8:28 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Reto Kromer
[-- Attachment #1: Type: message/rfc822, Size: 2663 bytes --]
From: Reto Kromer <lists@reto.ch>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH v6] gcc: Don't disable '-ftree-vectorize' if gcc version is 13 or newer
Date: Mon, 16 Jun 2025 10:28:37 +0200
Message-ID: <0775c411-ecdc-4198-9ff1-dba4eafb3613@mail.infomaniak.com>
Martijn van Beurden wrote:
>So, there is a proposal to close the flac and flac-dev mailing
>lists.
>I'd like to know whether you would be willing to move over to
>GitHub discussions. GitHub would be the first choice because
>most discussions already happen there anyway.
+1
Kind regards from Reto
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [FFmpeg-devel] [PATCH v6] gcc: Don't disable '-ftree-vectorize' if gcc version is 13 or newer
[not found] ` <0775c411-ecdc-4198-9ff1-dba4eafb3613@mail.infomaniak.com>
@ 2025-06-16 8:29 ` Reto Kromer via ffmpeg-devel
2025-06-16 8:52 ` Kieran Kunhya via ffmpeg-devel
0 siblings, 1 reply; 5+ messages in thread
From: Reto Kromer via ffmpeg-devel @ 2025-06-16 8:29 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Reto Kromer
[-- Attachment #1: Type: message/rfc822, Size: 2451 bytes --]
From: Reto Kromer <lists@reto.ch>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH v6] gcc: Don't disable '-ftree-vectorize' if gcc version is 13 or newer
Date: Mon, 16 Jun 2025 10:29:35 +0200
Message-ID: <42ae1795-533a-4b67-a813-699da00de8e7@mail.infomaniak.com>
Oops, sorry for the noise. Reto
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [FFmpeg-devel] [PATCH v6] gcc: Don't disable '-ftree-vectorize' if gcc version is 13 or newer
2025-06-16 8:29 ` Reto Kromer via ffmpeg-devel
@ 2025-06-16 8:52 ` Kieran Kunhya via ffmpeg-devel
0 siblings, 0 replies; 5+ messages in thread
From: Kieran Kunhya via ffmpeg-devel @ 2025-06-16 8:52 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Kieran Kunhya, Reto Kromer
[-- Attachment #1: Type: message/rfc822, Size: 4417 bytes --]
From: Kieran Kunhya <kieran618@googlemail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Cc: Reto Kromer <lists@reto.ch>
Subject: Re: [FFmpeg-devel] [PATCH v6] gcc: Don't disable '-ftree-vectorize' if gcc version is 13 or newer
Date: Mon, 16 Jun 2025 10:52:16 +0200
Message-ID: <CABGuwEkw6UQXqY0+zABzF6PvpXCkRV7symH=uh+g+sw5vkLzdg@mail.gmail.com>
On Mon, 16 Jun 2025, 10:29 Reto Kromer via ffmpeg-devel, <
ffmpeg-devel@ffmpeg.org> wrote:
>
>
>
> ---------- Forwarded message ----------
> From: Reto Kromer <lists@reto.ch>
> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
> Cc:
> Bcc:
> Date: Mon, 16 Jun 2025 10:29:35 +0200
> Subject: Re: [FFmpeg-devel] [PATCH v6] gcc: Don't disable
> '-ftree-vectorize' if gcc version is 13 or newer
> Oops, sorry for the noise. Reto
>
>
> ---------- Forwarded message ----------
> From: Reto Kromer via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
> Cc: Reto Kromer <lists@reto.ch>
> Bcc:
> Date: Mon, 16 Jun 2025 10:29:35 +0200
> Subject: Re: [FFmpeg-devel] [PATCH v6] gcc: Don't disable
> '-ftree-vectorize' if gcc version is 13 or newer
>
Glad to see it's not just me getting a forwarded copy of my own emails.
Kieran
>
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-06-16 8:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-16 8:11 [FFmpeg-devel] [PATCH v6] gcc: Don't disable '-ftree-vectorize' if gcc version is 13 or newer Martin Storsjö
2025-06-16 8:26 ` Martin Storsjö
2025-06-16 8:28 ` Reto Kromer via ffmpeg-devel
[not found] ` <0775c411-ecdc-4198-9ff1-dba4eafb3613@mail.infomaniak.com>
2025-06-16 8:29 ` Reto Kromer via ffmpeg-devel
2025-06-16 8:52 ` Kieran Kunhya via ffmpeg-devel
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git