From b5137ffd8367404ff35631b170bc9a29e9ff5c04 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sun, 18 Sep 2022 23:25:58 -0700 Subject: [PATCH] [TableGen] Optimize APInt |= with setBit. NFC --- llvm/utils/TableGen/CodeEmitterGen.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/utils/TableGen/CodeEmitterGen.cpp b/llvm/utils/TableGen/CodeEmitterGen.cpp index 1d00c3c..004f94f 100644 --- a/llvm/utils/TableGen/CodeEmitterGen.cpp +++ b/llvm/utils/TableGen/CodeEmitterGen.cpp @@ -370,8 +370,8 @@ void CodeEmitterGen::emitInstructionBaseValues( // Start by filling in fixed values. APInt Value(BitWidth, 0); for (unsigned i = 0, e = BI->getNumBits(); i != e; ++i) { - if (BitInit *B = dyn_cast(BI->getBit(e - i - 1))) - Value |= APInt(BitWidth, (uint64_t)B->getValue()) << (e - i - 1); + if (auto *B = dyn_cast(BI->getBit(i)); B && B->getValue()) + Value.setBit(i); } o << " "; emitInstBits(o, Value); -- 2.7.4