@@ -6260,21 +6260,22 @@ bool llvm::canIgnoreSignBitOfNaN(const Use &U) {
62606260}
62616261
62626262Value *llvm::isBytewiseValue (Value *V, const DataLayout &DL) {
6263+ unsigned ByteWidth = DL.getByteWidth ();
62636264
62646265 // All byte-wide stores are splatable, even of arbitrary variables.
6265- if (V->getType ()->isIntegerTy (8 ))
6266+ if (V->getType ()->isIntegerTy (ByteWidth ))
62666267 return V;
62676268
62686269 LLVMContext &Ctx = V->getContext ();
62696270
62706271 // Undef don't care.
6271- auto *UndefInt8 = UndefValue::get (Type::getInt8Ty (Ctx));
6272+ auto *UndefByte = UndefValue::get (Type::getIntNTy (Ctx, ByteWidth ));
62726273 if (isa<UndefValue>(V))
6273- return UndefInt8 ;
6274+ return UndefByte ;
62746275
62756276 // Return poison for zero-sized type.
62766277 if (DL.getTypeStoreSize (V->getType ()).isZero ())
6277- return PoisonValue::get (Type::getInt8Ty (Ctx));
6278+ return PoisonValue::get (Type::getIntNTy (Ctx, ByteWidth ));
62786279
62796280 Constant *C = dyn_cast<Constant>(V);
62806281 if (!C) {
@@ -6289,7 +6290,7 @@ Value *llvm::isBytewiseValue(Value *V, const DataLayout &DL) {
62896290
62906291 // Handle 'null' ConstantArrayZero etc.
62916292 if (C->isNullValue ())
6292- return Constant::getNullValue (Type::getInt8Ty (Ctx));
6293+ return Constant::getNullValue (Type::getIntNTy (Ctx, ByteWidth ));
62936294
62946295 // Constant floating-point values can be handled as integer values if the
62956296 // corresponding integer value is "byteable". An important case is 0.0.
@@ -6306,13 +6307,14 @@ Value *llvm::isBytewiseValue(Value *V, const DataLayout &DL) {
63066307 : nullptr ;
63076308 }
63086309
6309- // We can handle constant integers that are multiple of 8 bits .
6310+ // We can handle constant integers that are multiple of the byte width .
63106311 if (ConstantInt *CI = dyn_cast<ConstantInt>(C)) {
6311- if (CI->getBitWidth () % 8 == 0 ) {
6312- assert (CI->getBitWidth () > 8 && " 8 bits should be handled above!" );
6313- if (!CI->getValue ().isSplat (8 ))
6312+ if (CI->getBitWidth () % ByteWidth == 0 ) {
6313+ assert (CI->getBitWidth () > ByteWidth &&
6314+ " single byte should be handled above!" );
6315+ if (!CI->getValue ().isSplat (ByteWidth))
63146316 return nullptr ;
6315- return ConstantInt::get (Ctx, CI->getValue ().trunc (8 ));
6317+ return ConstantInt::get (Ctx, CI->getValue ().trunc (ByteWidth ));
63166318 }
63176319 }
63186320
@@ -6332,23 +6334,23 @@ Value *llvm::isBytewiseValue(Value *V, const DataLayout &DL) {
63326334 return LHS;
63336335 if (!LHS || !RHS)
63346336 return nullptr ;
6335- if (LHS == UndefInt8 )
6337+ if (LHS == UndefByte )
63366338 return RHS;
6337- if (RHS == UndefInt8 )
6339+ if (RHS == UndefByte )
63386340 return LHS;
63396341 return nullptr ;
63406342 };
63416343
63426344 if (ConstantDataSequential *CA = dyn_cast<ConstantDataSequential>(C)) {
6343- Value *Val = UndefInt8 ;
6345+ Value *Val = UndefByte ;
63446346 for (uint64_t I = 0 , E = CA->getNumElements (); I != E; ++I)
63456347 if (!(Val = Merge (Val, isBytewiseValue (CA->getElementAsConstant (I), DL))))
63466348 return nullptr ;
63476349 return Val;
63486350 }
63496351
63506352 if (isa<ConstantAggregate>(C)) {
6351- Value *Val = UndefInt8 ;
6353+ Value *Val = UndefByte ;
63526354 for (Value *Op : C->operands ())
63536355 if (!(Val = Merge (Val, isBytewiseValue (Op, DL))))
63546356 return nullptr ;
0 commit comments