Skip to content

Commit

Permalink
[InstCombine] Use APInt::getSplat()
Browse files Browse the repository at this point in the history
Split off from #80309.
  • Loading branch information
nikic committed Aug 13, 2024
1 parent 53c41f9 commit 4d97ad5
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,11 @@ Instruction *InstCombinerImpl::SimplifyAnyMemSet(AnyMemSetInst *MI) {

// memset(s,c,n) -> store s, c (for n=1,2,4,8)
if (Len <= 8 && isPowerOf2_32((uint32_t)Len)) {
Type *ITy = IntegerType::get(MI->getContext(), Len*8); // n=1 -> i8.

Value *Dest = MI->getDest();

// Extract the fill value and store.
const uint64_t Fill = FillC->getZExtValue()*0x0101010101010101ULL;
Constant *FillVal = ConstantInt::get(ITy, Fill);
Constant *FillVal = ConstantInt::get(
MI->getContext(), APInt::getSplat(Len * 8, FillC->getValue()));
StoreInst *S = Builder.CreateStore(FillVal, Dest, MI->isVolatile());
S->copyMetadata(*MI, LLVMContext::MD_DIAssignID);
auto replaceOpForAssignmentMarkers = [FillC, FillVal](auto *DbgAssign) {
Expand Down

0 comments on commit 4d97ad5

Please sign in to comment.