@@ -1675,11 +1675,8 @@ void NVPTXAsmPrinter::bufferAggregateConstant(const Constant *CPV,
16751675 const DataLayout &DL = getDataLayout ();
16761676
16771677 auto ExtendBuffer = [](APInt Val, AggBuffer *Buffer) {
1678- for (unsigned _ : llvm::seq (Val.getBitWidth () / 8 )) {
1679- uint8_t Byte = Val.getLoBits (8 ).getZExtValue ();
1680- Buffer->addBytes (&Byte, 1 , 1 );
1681- Val.lshrInPlace (8 );
1682- }
1678+ for (unsigned I : llvm::seq (Val.getBitWidth () / 8 ))
1679+ Buffer->addByte (Val.extractBitsAsZExtValue (8 , I * 8 ));
16831680 };
16841681
16851682 // Integers of arbitrary width
@@ -1704,23 +1701,21 @@ void NVPTXAsmPrinter::bufferAggregateConstant(const Constant *CPV,
17041701 }
17051702
17061703 if (const auto *CDS = dyn_cast<ConstantDataSequential>(CPV)) {
1707- if (CDS->getNumElements ())
1708- for (unsigned i : llvm::seq (CDS->getNumElements ()))
1709- bufferLEByte (cast<Constant>(CDS->getElementAsConstant (i)), 0 ,
1710- aggBuffer);
1704+ for (unsigned I : llvm::seq (CDS->getNumElements ()))
1705+ bufferLEByte (cast<Constant>(CDS->getElementAsConstant (I)), 0 , aggBuffer);
17111706 return ;
17121707 }
17131708
17141709 if (isa<ConstantStruct>(CPV)) {
17151710 if (CPV->getNumOperands ()) {
17161711 StructType *ST = cast<StructType>(CPV->getType ());
1717- for (unsigned i : llvm::seq (CPV->getNumOperands ())) {
1718- int EndOffset = (i + 1 == CPV->getNumOperands ())
1712+ for (unsigned I : llvm::seq (CPV->getNumOperands ())) {
1713+ int EndOffset = (I + 1 == CPV->getNumOperands ())
17191714 ? DL.getStructLayout (ST)->getElementOffset (0 ) +
17201715 DL.getTypeAllocSize (ST)
1721- : DL.getStructLayout (ST)->getElementOffset (i + 1 );
1722- int Bytes = EndOffset - DL.getStructLayout (ST)->getElementOffset (i );
1723- bufferLEByte (cast<Constant>(CPV->getOperand (i )), Bytes, aggBuffer);
1716+ : DL.getStructLayout (ST)->getElementOffset (I + 1 );
1717+ int Bytes = EndOffset - DL.getStructLayout (ST)->getElementOffset (I );
1718+ bufferLEByte (cast<Constant>(CPV->getOperand (I )), Bytes, aggBuffer);
17241719 }
17251720 }
17261721 return ;
0 commit comments