XChy wrote: > Then the optimization in this patch is handled somewhere? Yes. What we need to do is just making `A pred C ? (A << BW - 1) : 1` -> `ZExt(A pred C ? A < 0 : 1)`. This form is easier to fold in other optimization. https://github.com/llvm/llvm-project/pull/69961