https://github.com/davemgreen commented: Thanks - the AArch64 test and patterns all look good to me now. I can't say much about the RISCV parts and I think there might be other (untested) cases where things can still go wrong with TRUNCATE_SSAT_U. https://github.com/llvm/llvm-project/pull/99418