Missed constant replacement opportunity with llvm.assume?

As of ToT it seems that even the simplest cases of assumes involving equality between an instruction and a constant don’t cause an instruction RAUW constant.

In the attached example, %channels is assumed to be 3, leading to a missed optimization opportunity with %src_c.

Am I overlooking something that would cause this optimization to be invalid?

v/r,
Josh

convert_grayscale_u8SCXY_u8SCXY.ll (3.03 KB)

Opened a bug with a minimum reproducing example:

https://llvm.org/bugs/show_bug.cgi?id=23055

It seems to me the issue is that InstCombiner successfully simplifies return values when they can be proven constant, but misses the same optimization opportunity for store values.

v/r,
Josh