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

Patrick Simmons via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 27 11:50:34 PDT 2025


================
@@ -1977,6 +1989,37 @@ Value *AMDGPUCodeGenPrepareImpl::applyFractPat(IRBuilder<> &Builder,
   return insertValues(Builder, FractArg->getType(), ResultVals);
 }
 
+bool AMDGPUCodeGenPrepareImpl::visitCtpop(IntrinsicInst &I) {
+  uint32_t BitWidth, DestinationWidth, IntrinsicWidth;
+  if (!I.hasOneUse() || !I.getType()->isIntegerTy() ||
+      !ST.hasBCNT(BitWidth = I.getType()->getIntegerBitWidth()))
----------------
linuxrocks123 wrote:

Assignments promoted to full lines.

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


More information about the cfe-commits mailing list