@@ -6319,21 +6319,22 @@ std::optional<bool> llvm::computeKnownFPSignBit(const Value *V, unsigned Depth,
6319
6319
}
6320
6320
6321
6321
Value *llvm::isBytewiseValue (Value *V, const DataLayout &DL) {
6322
+ unsigned ByteWidth = DL.getByteWidth ();
6322
6323
6323
6324
// All byte-wide stores are splatable, even of arbitrary variables.
6324
- if (V->getType ()->isIntegerTy (8 ))
6325
+ if (V->getType ()->isIntegerTy (ByteWidth ))
6325
6326
return V;
6326
6327
6327
6328
LLVMContext &Ctx = V->getContext ();
6328
6329
6329
6330
// Undef don't care.
6330
- auto *UndefInt8 = UndefValue::get (Type::getInt8Ty (Ctx));
6331
+ auto *UndefByte = UndefValue::get (Type::getIntNTy (Ctx, ByteWidth ));
6331
6332
if (isa<UndefValue>(V))
6332
- return UndefInt8 ;
6333
+ return UndefByte ;
6333
6334
6334
6335
// Return poison for zero-sized type.
6335
6336
if (DL.getTypeStoreSize (V->getType ()).isZero ())
6336
- return PoisonValue::get (Type::getInt8Ty (Ctx));
6337
+ return PoisonValue::get (Type::getIntNTy (Ctx, ByteWidth ));
6337
6338
6338
6339
Constant *C = dyn_cast<Constant>(V);
6339
6340
if (!C) {
@@ -6348,7 +6349,7 @@ Value *llvm::isBytewiseValue(Value *V, const DataLayout &DL) {
6348
6349
6349
6350
// Handle 'null' ConstantArrayZero etc.
6350
6351
if (C->isNullValue ())
6351
- return Constant::getNullValue (Type::getInt8Ty (Ctx));
6352
+ return Constant::getNullValue (Type::getIntNTy (Ctx, ByteWidth ));
6352
6353
6353
6354
// Constant floating-point values can be handled as integer values if the
6354
6355
// corresponding integer value is "byteable". An important case is 0.0.
@@ -6365,13 +6366,14 @@ Value *llvm::isBytewiseValue(Value *V, const DataLayout &DL) {
6365
6366
: nullptr ;
6366
6367
}
6367
6368
6368
- // We can handle constant integers that are multiple of 8 bits .
6369
+ // We can handle constant integers that are multiple of the byte width .
6369
6370
if (ConstantInt *CI = dyn_cast<ConstantInt>(C)) {
6370
- if (CI->getBitWidth () % 8 == 0 ) {
6371
- assert (CI->getBitWidth () > 8 && " 8 bits should be handled above!" );
6372
- if (!CI->getValue ().isSplat (8 ))
6371
+ if (CI->getBitWidth () % ByteWidth == 0 ) {
6372
+ assert (CI->getBitWidth () > ByteWidth &&
6373
+ " single byte should be handled above!" );
6374
+ if (!CI->getValue ().isSplat (ByteWidth))
6373
6375
return nullptr ;
6374
- return ConstantInt::get (Ctx, CI->getValue ().trunc (8 ));
6376
+ return ConstantInt::get (Ctx, CI->getValue ().trunc (ByteWidth ));
6375
6377
}
6376
6378
}
6377
6379
@@ -6391,23 +6393,23 @@ Value *llvm::isBytewiseValue(Value *V, const DataLayout &DL) {
6391
6393
return LHS;
6392
6394
if (!LHS || !RHS)
6393
6395
return nullptr ;
6394
- if (LHS == UndefInt8 )
6396
+ if (LHS == UndefByte )
6395
6397
return RHS;
6396
- if (RHS == UndefInt8 )
6398
+ if (RHS == UndefByte )
6397
6399
return LHS;
6398
6400
return nullptr ;
6399
6401
};
6400
6402
6401
6403
if (ConstantDataSequential *CA = dyn_cast<ConstantDataSequential>(C)) {
6402
- Value *Val = UndefInt8 ;
6404
+ Value *Val = UndefByte ;
6403
6405
for (uint64_t I = 0 , E = CA->getNumElements (); I != E; ++I)
6404
6406
if (!(Val = Merge (Val, isBytewiseValue (CA->getElementAsConstant (I), DL))))
6405
6407
return nullptr ;
6406
6408
return Val;
6407
6409
}
6408
6410
6409
6411
if (isa<ConstantAggregate>(C)) {
6410
- Value *Val = UndefInt8 ;
6412
+ Value *Val = UndefByte ;
6411
6413
for (Value *Op : C->operands ())
6412
6414
if (!(Val = Merge (Val, isBytewiseValue (Op, DL))))
6413
6415
return nullptr ;
0 commit comments