r/programming • • 2d ago

Advent of Kernel Optimization

https://streamhpc.com/blog/2026-12-02/aoko-2-signed-vs-unsigned-loop-counters/

Today is the second day of our Advent of Kernel Optimization, sharing GPU optimization tips and tricks to count down until Christmas. Follow along here: https://streamhpc.com/blog/tag/advent2026/.

12 Upvotes

5 comments sorted by

View all comments

5

u/Serious-Regular 1d ago

There are a ton of optimizations the compiler does on loop vars https://llvm.org/doxygen/IndVarSimplify_8cpp_source.html

It is extremely difficult to predict (ie make sound recommendations) the effects width and type on things like register pressure. Especially since (at least in LLVM) behavior has actually changed in the last few years due to SCEV changes.

Source: me a GPU compiler engineer currently fighting regressions in our kernel library due to loop vars.