[llvm] [AMDGPU] Lower uniform usubsat to SOP (PR #203155)

Anshil Gandhi via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 24 08:13:04 PDT 2026


gandhi56 wrote:

> > * i16: route uniform `usubsat` through `promoteUniformOpToI32` instead of a TableGen pattern that hard-codes the 0xffff masks. This exposes the zero-extends as real DAG nodes so KnownBits can fold the masks when the high bits are already known zero; the promoted i32 usubsat then reuses the scalar pattern. Promote-and-truncate is safe for usubsat because the result always fits in the narrow type (unlike uaddsat).
> 
> Could i16 `uaddsat` be implemented with truncate(min(zero-extend(a) + zero-extend(b), 0xffff))?

Yup, definitely. Should I include it in this PR?

https://github.com/llvm/llvm-project/pull/203155


More information about the llvm-commits mailing list