[llvm] 47ff304 - [RISCV] Use findFirstSet instead of countTrailingZeros. NFC
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 4 18:07:34 PST 2022
Author: Craig Topper
Date: 2022-12-04T18:00:36-08:00
New Revision: 47ff3042e79b37bbfc19617836cfba1dbbdfec38
URL: https://github.com/llvm/llvm-project/commit/47ff3042e79b37bbfc19617836cfba1dbbdfec38
DIFF: https://github.com/llvm/llvm-project/commit/47ff3042e79b37bbfc19617836cfba1dbbdfec38.diff
LOG: [RISCV] Use findFirstSet instead of countTrailingZeros. NFC
findFirstSet is a wrapper around countTrailingZeros so they are
equivalent here, but I think findFirstSet more cleary describes
the algorithm here.
Added:
Modified:
llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
index e57c4875c2bf..73cfef8dad37 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
@@ -296,9 +296,9 @@ InstSeq generateInstSeq(int64_t Val, const FeatureBitset &ActiveFeatures) {
// Search for each bit and build corresponding BCLRI/BSETI.
if (Opc > 0) {
while (Hi != 0) {
- unsigned Bit = countTrailingZeros(Hi);
+ unsigned Bit = findFirstSet(Hi, ZB_Undefined);
TmpSeq.emplace_back(Opc, Bit + 32);
- Hi &= ~(1 << Bit);
+ Hi &= (Hi - 1); // Clear lowest set bit.
}
if (TmpSeq.size() < Res.size())
Res = TmpSeq;
More information about the llvm-commits
mailing list