Skip to content

Commit 1fde349

Browse files
nikicakiramenai
authored andcommitted
[InstCombine] Use APInt::getSplat()
Split off from llvm/llvm-project#80309.
1 parent 7d321e7 commit 1fde349

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,11 @@ Instruction *InstCombinerImpl::SimplifyAnyMemSet(AnyMemSetInst *MI) {
270270

271271
// memset(s,c,n) -> store s, c (for n=1,2,4,8)
272272
if (Len <= 8 && isPowerOf2_32((uint32_t)Len)) {
273-
Type *ITy = IntegerType::get(MI->getContext(), Len*8); // n=1 -> i8.
274-
275273
Value *Dest = MI->getDest();
276274

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

0 commit comments

Comments
 (0)