[llvm] [AMDGPU] Generate s_absdiff_i32 (PR #164835)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 23 08:49:25 PDT 2025


================
@@ -110,6 +110,21 @@ define amdgpu_ps i32 @abs32(i32 inreg %val0) {
   ret i32 %zext
 }
 
+define amdgpu_ps i32 @absdiff32(i32 inreg %val0, i32 inreg %val1) {
+; CHECK-LABEL: absdiff32:
+; CHECK:       ; %bb.0:
+; CHECK-NEXT:    s_absdiff_i32 s0, s0, s1
+; CHECK-NEXT:    s_cselect_b64 s[0:1], -1, 0
+; CHECK-NEXT:    v_cndmask_b32_e64 v0, 0, 1, s[0:1]
+; CHECK-NEXT:    v_readfirstlane_b32 s0, v0
----------------
jayfoad wrote:

Codegen is terrible here, but that's not your fault. Should be:

```suggestion
; CHECK-NEXT:    s_cselect_b32 s0, 1, 0
```

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


More information about the llvm-commits mailing list