[PATCH] D45344: [InstCombine] Fold malloc + memset to calloc even for llvm.memset
Dávid Bolvanský via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 6 11:25:59 PDT 2018
xbolva00 updated this revision to Diff 141388.
https://reviews.llvm.org/D45344
Files:
lib/Transforms/Utils/SimplifyLibCalls.cpp
Index: lib/Transforms/Utils/SimplifyLibCalls.cpp
===================================================================
--- lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -883,6 +883,9 @@
if (auto *Calloc = foldMallocMemset(CI, B, *TLI))
return Calloc;
+ if (CI->getCalledFunction()->isIntrinsic())
+ return nullptr;
+
// memset(p, v, n) -> llvm.memset(align 1 p, v, n)
Value *Val = B.CreateIntCast(CI->getArgOperand(1), B.getInt8Ty(), false);
B.CreateMemSet(CI->getArgOperand(0), Val, CI->getArgOperand(2), 1);
@@ -2219,7 +2222,8 @@
return optimizeLog(CI, Builder);
case Intrinsic::sqrt:
return optimizeSqrt(CI, Builder);
- // TODO: Use foldMallocMemset() with memset intrinsic.
+ case Intrinsic::memset:
+ return optimizeMemSet(CI, Builder);
default:
return nullptr;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45344.141388.patch
Type: text/x-patch
Size: 882 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180406/ab538133/attachment.bin>
More information about the llvm-commits
mailing list