kazutakahirata wrote: The patch looks good. Do you happen to have a test case that tripped on `assert(isVariable() ...` in `getCost()`? If so, we should incorporate that into this PR. https://github.com/llvm/llvm-project/pull/86630