[llvm] [GISel][RISCV] Compute CTPOP of small odd-sized integer correctly (PR #168559)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 18 10:06:58 PST 2025


================
@@ -7678,15 +7678,9 @@ LegalizerHelper::lowerBitCount(MachineInstr &MI) {
     unsigned Size = Ty.getSizeInBits();
     MachineIRBuilder &B = MIRBuilder;
 
-    // Lift odd-size integer to multiple of 8 bit.
-    if (Size % 8 != 0) {
-      LLT NewTy = LLT::scalar(alignTo(Size, 8));
-      Observer.changingInstr(MI);
-      widenScalarSrc(MI, NewTy, 1, TargetOpcode::G_ZEXT);
-      widenScalarDst(MI, NewTy, 0);
-      Observer.changedInstr(MI);
-      return Legalized;
-    }
+    // Bail out on irregular type lengths.
+    if (Size >= 128 || Size % 8 != 0)
----------------
topperc wrote:

I messed up my original comment and tried to edit it. This should be Size > 128 not >=

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


More information about the llvm-commits mailing list