Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider dropping bfloat16 demotion pass #55479

Closed
giordano opened this issue Aug 12, 2024 · 1 comment · Fixed by #55486
Closed

Consider dropping bfloat16 demotion pass #55479

giordano opened this issue Aug 12, 2024 · 1 comment · Fixed by #55486
Labels
compiler:llvm For issues that relate to LLVM float16

Comments

@giordano
Copy link
Contributor

If I'm interpreting llvm/llvm-project#97975 (comment) correctly, LLVM's problematic excess precision handling might not be in use with bfloat. If we can verify this, maybe we can just get rid of the demote pass for BFloat16 and have_bf16.

The other condition is that all our targets that do not support bfloat (i.e., most of them) properly legalize bfloat instructions to something that they do support. IIRC I encountered some instruction selection failures when first working on this, but those might have been fixed now that we're on a more recent version of LLVM.

Originally posted by @maleadt in #55417 (comment)

@maleadt
Copy link
Member

maleadt commented Aug 13, 2024

Here's a test script: https://godbolt.org/z/bxa5f9r8P

Looking at Float16 on x86_64:

  • up until LLVM 10, operations are incorrectly performed in excessive precision doing mul + mul + add without conversions in between
  • starting with LLVM 11, there's conversions surrounding every mul and add

For BFloat16:

  • up until LLVM 15, same thing as for Float16 (excessive precision)
  • starting with LLVM 16, everything seems OK

Given the list of affected targets on llvm/llvm-project#97975, we can probably disable the demote pass altogether, except for PPC where we need to still demote Float16 (https://godbolt.org/z/7eKs6ErvG). Since AVR is also affected, it might be interesting to keep the pass available for AVRCompiler.jl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:llvm For issues that relate to LLVM float16
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants