Custom width intergers in Clang/LLVM

Specialised types for different problems? Now there is a thought!

Not really. That is a clang patch that is not relevant for Julia.

Julia already had access to the underlying LLVM IR that allows for custom integer widths, that patch just exposed it through a Clang library to C++.

The issue with custom widths on desktop platforms/most computers is that the underlying hardware really isn’t going to be performant for the non-standard widths. Sure, I can make LLVM give me a 24 bit integer, but the datapath for the CPU is still going to be the 32 or 64 bit pathway (or 128, 256, 512 for newer processors ALUs). If you have small enough data types, you could do bit packing and try to do more than one operation per cycle in the same amount of space - and that is essentially what many SIMD operations are doing (using a larger datapath to compute with multiple smaller numbers at the same time).

The main area where the LLVM IR for arbitrary integers is nice is for FPGA HLS tools. On FPGAs you have complete control over the widths of the datapaths, so optimizing away unused bits can be done (and saves space/power). So making a 15 bit integer on FPGAs can actually have an effect on the resulting hardware and performance as opposed to a 15 bit integer on your computer, which has little to no effect.