@@ -6348,21 +6348,22 @@ std::optional<bool> llvm::computeKnownFPSignBit(const Value *V, unsigned Depth,
63486348}
63496349
63506350Value *llvm::isBytewiseValue (Value *V, const DataLayout &DL) {
6351+ unsigned ByteWidth = DL.getByteWidth ();
63516352
63526353 // All byte-wide stores are splatable, even of arbitrary variables.
6353- if (V->getType ()->isIntegerTy (8 ))
6354+ if (V->getType ()->isIntegerTy (ByteWidth ))
63546355 return V;
63556356
63566357 LLVMContext &Ctx = V->getContext ();
63576358
63586359 // Undef don't care.
6359- auto *UndefInt8 = UndefValue::get (Type::getInt8Ty (Ctx));
6360+ auto *UndefByte = UndefValue::get (Type::getIntNTy (Ctx, ByteWidth ));
63606361 if (isa<UndefValue>(V))
6361- return UndefInt8 ;
6362+ return UndefByte ;
63626363
63636364 // Return poison for zero-sized type.
63646365 if (DL.getTypeStoreSize (V->getType ()).isZero ())
6365- return PoisonValue::get (Type::getInt8Ty (Ctx));
6366+ return PoisonValue::get (Type::getIntNTy (Ctx, ByteWidth ));
63666367
63676368 Constant *C = dyn_cast<Constant>(V);
63686369 if (!C) {
@@ -6377,7 +6378,7 @@ Value *llvm::isBytewiseValue(Value *V, const DataLayout &DL) {
63776378
63786379 // Handle 'null' ConstantArrayZero etc.
63796380 if (C->isNullValue ())
6380- return Constant::getNullValue (Type::getInt8Ty (Ctx));
6381+ return Constant::getNullValue (Type::getIntNTy (Ctx, ByteWidth ));
63816382
63826383 // Constant floating-point values can be handled as integer values if the
63836384 // corresponding integer value is "byteable". An important case is 0.0.
@@ -6394,13 +6395,14 @@ Value *llvm::isBytewiseValue(Value *V, const DataLayout &DL) {
63946395 : nullptr ;
63956396 }
63966397
6397- // We can handle constant integers that are multiple of 8 bits .
6398+ // We can handle constant integers that are multiple of the byte width .
63986399 if (ConstantInt *CI = dyn_cast<ConstantInt>(C)) {
6399- if (CI->getBitWidth () % 8 == 0 ) {
6400- assert (CI->getBitWidth () > 8 && " 8 bits should be handled above!" );
6401- if (!CI->getValue ().isSplat (8 ))
6400+ if (CI->getBitWidth () % ByteWidth == 0 ) {
6401+ assert (CI->getBitWidth () > ByteWidth &&
6402+ " single byte should be handled above!" );
6403+ if (!CI->getValue ().isSplat (ByteWidth))
64026404 return nullptr ;
6403- return ConstantInt::get (Ctx, CI->getValue ().trunc (8 ));
6405+ return ConstantInt::get (Ctx, CI->getValue ().trunc (ByteWidth ));
64046406 }
64056407 }
64066408
@@ -6420,23 +6422,23 @@ Value *llvm::isBytewiseValue(Value *V, const DataLayout &DL) {
64206422 return LHS;
64216423 if (!LHS || !RHS)
64226424 return nullptr ;
6423- if (LHS == UndefInt8 )
6425+ if (LHS == UndefByte )
64246426 return RHS;
6425- if (RHS == UndefInt8 )
6427+ if (RHS == UndefByte )
64266428 return LHS;
64276429 return nullptr ;
64286430 };
64296431
64306432 if (ConstantDataSequential *CA = dyn_cast<ConstantDataSequential>(C)) {
6431- Value *Val = UndefInt8 ;
6433+ Value *Val = UndefByte ;
64326434 for (uint64_t I = 0 , E = CA->getNumElements (); I != E; ++I)
64336435 if (!(Val = Merge (Val, isBytewiseValue (CA->getElementAsConstant (I), DL))))
64346436 return nullptr ;
64356437 return Val;
64366438 }
64376439
64386440 if (isa<ConstantAggregate>(C)) {
6439- Value *Val = UndefInt8 ;
6441+ Value *Val = UndefByte ;
64406442 for (Value *Op : C->operands ())
64416443 if (!(Val = Merge (Val, isBytewiseValue (Op, DL))))
64426444 return nullptr ;
0 commit comments