Skip to content

Commit 4d97ad5

Browse files
committed
[InstCombine] Use APInt::getSplat()
Split off from #80309.
1 parent 53c41f9 commit 4d97ad5

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
@@ -260,13 +260,11 @@ Instruction *InstCombinerImpl::SimplifyAnyMemSet(AnyMemSetInst *MI) {
260260

261261
// memset(s,c,n) -> store s, c (for n=1,2,4,8)
262262
if (Len <= 8 && isPowerOf2_32((uint32_t)Len)) {
263-
Type *ITy = IntegerType::get(MI->getContext(), Len*8); // n=1 -> i8.
264-
265263
Value *Dest = MI->getDest();
266264

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

0 commit comments

Comments
 (0)