[llvm] 4d97ad5 - [InstCombine] Use APInt::getSplat()

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 13 06:04:39 PDT 2024


Author: Nikita Popov
Date: 2024-08-13T15:04:23+02:00
New Revision: 4d97ad59f9ef4a26a52be8ff9bfcfa58d5039eb4

URL: https://github.com/llvm/llvm-project/commit/4d97ad59f9ef4a26a52be8ff9bfcfa58d5039eb4
DIFF: https://github.com/llvm/llvm-project/commit/4d97ad59f9ef4a26a52be8ff9bfcfa58d5039eb4.diff

LOG: [InstCombine] Use APInt::getSplat()

Split off from https://github.com/llvm/llvm-project/pull/80309.

Added: 
    

Modified: 
    llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index a38c990b9ea83a..ab3d8ca8db6f75 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -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) {


        


More information about the llvm-commits mailing list