Skip to content

Commit

Permalink
Preserve base type == 16 for memset
Browse files Browse the repository at this point in the history
Preserve base type == 16 not only for memcpy, but also for memset lowering
  • Loading branch information
admitric authored and igcbot committed Jun 21, 2023
1 parent a8fedcd commit 1a739c9
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,8 @@ void ReplaceUnsupportedIntrinsics::replaceMemcpy(IntrinsicInst* I)

IGCLLVM::IRBuilder<> Builder(MC);

// BaseSize is flag if we want to handle algorithm in general way
// or want to keep size of base type to further optimizations
// BaseSize == 32 if we want to handle algorithm in general way
// or different value if want to keep size of base type to further optimizations
uint32_t BaseSize = 0;
Type* RawDstType = IGCLLVM::getNonOpaquePtrEltTy(Dst->stripPointerCasts()->getType());
if (Type* BaseType = GetBaseType(RawDstType))
Expand Down Expand Up @@ -800,14 +800,25 @@ void ReplaceUnsupportedIntrinsics::replaceMemset(IntrinsicInst* I)

IGCLLVM::IRBuilder<> Builder(MS);

// BaseSize == 32 if we want to handle algorithm in general way
// or different value if want to keep size of base type to further optimizations
uint32_t BaseSize = 0;
Type* RawDstType = IGCLLVM::getNonOpaquePtrEltTy(Dst->stripPointerCasts()->getType());
if (Type* BaseType = GetBaseType(RawDstType))
BaseSize = BaseType->getScalarSizeInBits();

if (BaseSize != 16)
// size 32 is equal to size of i32, so general algorithm will be applied
BaseSize = 32;

ConstantInt* CI = dyn_cast<ConstantInt>(LPCount);
if (CI)
{
uint32_t Count = (uint32_t)CI->getZExtValue();

Type* VecTys[8];
uint32_t Len, NewCount;
generalGroupI8Stream(C, Count, Align, NewCount, VecTys, Len);
generalGroupI8Stream(C, Count, Align, NewCount, VecTys, Len, BaseSize);

Value* NewDst, * vDst, * vSrc;
uint32_t BOfst = 0; // Byte offset
Expand Down

0 comments on commit 1a739c9

Please sign in to comment.