[flang-commits] [llvm] [clang] [flang] [InstCombine] Canonicalize constant GEPs to i8 source element type (PR #68882)

via flang-commits flang-commits at lists.llvm.org
Thu Jan 4 07:30:58 PST 2024


BukeBeyond wrote:

### For us, this is the Most Productive update of the year!

We are ambitiously building a new language b.  b extends and generates C++26, just like C++ generated C in 1979.  b runs majority of the same CPU code on mainstream GPUs over just Vulkan.  It features single file modules, reflection, properties, unified pointers, automatic serialization and UI.  The UI is real-time ray-traced with depth and surface properties. The library classes, including custom vectors and images are written with the most modern language features, such as concepts, templates, converters, properties and lambdas.

This project was made possible by the great advances in Clang's IR generation for OpenCL, and the cutting edge Clspv, which converts the IR to SPIRV for Vulkan.

Over the years, majority of the bugs we have encountered with Clspv have been due to incomplete handling of the Typed GEPs.  Clspv is still struggling with these bugs, but we have been bypassing them by eliminating the Typed GEPs sent over to Clspv.  

We have been utilizing Clang's exclusive inlining optimizations combined with private address (GPU register) copies of structures in global addresses (GPU main memory).  For stores, we have been manually computing the field addresses.  These peculiar workarounds, finally allowed the optimizations to flatten and eliminate the Typed GEPs.  Otherwise the Typed GEPs leaked over to Clspv, and all sorts of bugs were triggered...

After this incredible update, we no longer have to do these tricks with the read copies, and the manual write addresses!  Clang's inlining and optimizations are now able to eliminate the Typed GEPs on their own!

So here is one of the most heterogeneous and ambitious examples, that Typed GEPs are not needed to run most of C++26 over Vulkan.  The Typed GEP design, in practice, has been a road block, at least for Clspv.

My first impression with the Typed GEP was that it was a mistake just like with the Typed (Non-Opaque) Pointers.  It proved to be minimum reward and maximum risk.  There was this potential of esoteric optimizations, and the elusive hardware-independent IR theory, but in practice, Typed GEPs daunted the majority of the transforms with unnecessary complexity, bugs and performance penalties.

So thank you Nikita for your wisdom, expertise, and taking this very important first step!

Happy New Year!

https://github.com/llvm/llvm-project/pull/68882


More information about the flang-commits mailing list