Skip to content

Re-enable BF16 on x86 in debug builds with Clang 22 or later#2781

Merged
copybara-service[bot] merged 2 commits intogoogle:masterfrom
johnplatts:hwy_x86_clang22_bf16_102425
Oct 24, 2025
Merged

Re-enable BF16 on x86 in debug builds with Clang 22 or later#2781
copybara-service[bot] merged 2 commits intogoogle:masterfrom
johnplatts:hwy_x86_clang22_bf16_102425

Conversation

@johnplatts
Copy link
Copy Markdown
Contributor

There is a recent fix in LLVM 22 that fixes the bug with _BFloat16 in debug builds on x86, and this bug was fixed in LLVM pull request llvm/llvm-project#164565 (which has been recently merged into the LLVM trunk).

It is now safe to define HWY_SSE2_HAVE_SCALAR_BF16_TYPE to 1 in debug builds with Clang 22 and later on x86 with the fix in llvm/llvm-project#164565.

Copy link
Copy Markdown
Member

@jan-wassenberg jan-wassenberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about we make the check >= 2300? The issue is that all the various pre-release LLVM versions already call themselves "22", but they might be before or after the fix. Or can we see more with HWY_COMPILER_CLANG3?

@stefson
Copy link
Copy Markdown

stefson commented Oct 24, 2025

@johnplatts do you think you can ask upstream llvm for a backport to llvm-21 branch? I could do that as well, but you might be better at explaining them why this would be a good candidate (:

@johnplatts
Copy link
Copy Markdown
Contributor Author

How about we make the check >= 2300? The issue is that all the various pre-release LLVM versions already call themselves "22", but they might be before or after the fix. Or can we see more with HWY_COMPILER_CLANG3?

A better alternative is HWY_COMPILER3_CLANG >= 220101 as Clang 22.1.1 is guaranteed to have the required fixes. I have updated this pull request to check for HWY_COMPILER3_CLANG >= 220101.

Copy link
Copy Markdown
Member

@jan-wassenberg jan-wassenberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, thanks for updating.

@copybara-service copybara-service bot merged commit 9a5d6bd into google:master Oct 24, 2025
36 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants