Skip to content

Commit 89d8739

Browse files
committed
resolve comment
1 parent f3a2955 commit 89d8739

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7678,15 +7678,9 @@ LegalizerHelper::lowerBitCount(MachineInstr &MI) {
76787678
unsigned Size = Ty.getSizeInBits();
76797679
MachineIRBuilder &B = MIRBuilder;
76807680

7681-
// Lift odd-size integer to multiple of 8 bit.
7682-
if (Size % 8 != 0) {
7683-
LLT NewTy = LLT::scalar(alignTo(Size, 8));
7684-
Observer.changingInstr(MI);
7685-
widenScalarSrc(MI, NewTy, 1, TargetOpcode::G_ZEXT);
7686-
widenScalarDst(MI, NewTy, 0);
7687-
Observer.changedInstr(MI);
7688-
return Legalized;
7689-
}
7681+
// Bail out on irregular type lengths.
7682+
if (Size >= 128 || Size % 8 != 0)
7683+
return UnableToLegalize;
76907684

76917685
// Count set bits in blocks of 2 bits. Default approach would be
76927686
// B2Count = { val & 0x55555555 } + { (val >> 1) & 0x55555555 }

llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,10 @@ RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget &ST)
238238
.clampScalar(0, sXLen, sXLen)
239239
.scalarSameSizeAs(1, 0);
240240
} else {
241-
CTPOPActions.maxScalar(0, sXLen).scalarSameSizeAs(1, 0).lower();
241+
CTPOPActions.widenScalarToNextPow2(0, /*Min*/ 8)
242+
.clampScalar(0, s8, sXLen)
243+
.scalarSameSizeAs(1, 0)
244+
.lower();
242245
}
243246

244247
getActionDefinitionsBuilder(G_CONSTANT)

0 commit comments

Comments
 (0)