Range metadata can be set on load and call of integer types in IR. I can hit significantly better codegen if the IR has range annotations on variables.
My first attempt used llvm.assume, but this doesn't appear to influence range metatdata or scalar evolution.
The code I'm working with is written in C++, compiled via clang. I'd like the authors to annotate the range on variables. Intrinsics, existing or bespoke, would be fine. Ideally the method would work on variables, but failing that annotating loads would still help.
I tried routing the count via alloca/store/load, with metadata on the load, but this is eliminated before reaching my pass. If I force matters, the trip via the stack thwarts scalar evolution anyway. Similarly a call that is eliminated later blocks scalar evolution.
I'm reasonably confident that an intrinsic that lowers to a load instruction will work but haven't cut the code yet. It wouldn't be as general as an int (*)(int) intrinsic either.