From: "Martin Storsjö" <martin@martin.st> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH v6] gcc: Don't disable '-ftree-vectorize' if gcc version is 13 or newer Date: Mon, 16 Jun 2025 11:11:07 +0300 Message-ID: <20250616081107.57114-1-martin@martin.st> (raw) 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".
next reply other threads:[~2025-06-16 8:11 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-06-16 8:11 Martin Storsjö [this message] 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
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20250616081107.57114-1-martin@martin.st \ --to=martin@martin.st \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
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