[clang] [llvm] [AMDGPU] Match bitsin(typeof(x)) - popcnt(x) to s_bcnt0_i32 (PR #164847)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 5 13:00:24 PST 2025


================
@@ -264,7 +264,9 @@ def S_BREV_B64 : SOP1_64 <"s_brev_b64",
 } // End isReMaterializable = 1, isAsCheapAsAMove = 1
 
 let Defs = [SCC] in {
-def S_BCNT0_I32_B32 : SOP1_32 <"s_bcnt0_i32_b32">;
+def S_BCNT0_I32_B32 : SOP1_32 <"s_bcnt0_i32_b32",
+  [(set i32:$sdst, (UniformBinFrag<sub> 32, (ctpop i32:$src0)))]
----------------
arsenm wrote:

```suggestion
  [(set i32:$sdst, (UniformBinFrag<sub> 32, (ctpop_oneuse i32:$src0)))]
```

Will need to put in AMDGPUInstructions.td 

`def ctpop_oneuse : HasOneUseUnaryOp<ctpop>;`

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


More information about the llvm-commits mailing list