tryMergingIntoMemset can only handle constant length memsets.
authorChris Lattner <sabre@nondot.org>
Sat, 8 Jan 2011 22:11:56 +0000 (22:11 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 8 Jan 2011 22:11:56 +0000 (22:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123090 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/MemCpyOptimizer.cpp

index 4210f0d9b790b3925cad1a573fe67fd0300f1926..76fab1cd281afd74e297f06a1c30dcaef30b73b2 100644 (file)
@@ -515,11 +515,12 @@ bool MemCpyOpt::processStore(StoreInst *SI, BasicBlock::iterator &BBI) {
 bool MemCpyOpt::processMemSet(MemSetInst *MSI, BasicBlock::iterator &BBI) {
   // See if there is another memset or store neighboring this memset which
   // allows us to widen out the memset to do a single larger store.
-  if (Instruction *I = tryMergingIntoMemset(MSI, MSI->getDest(),
-                                            MSI->getValue())) {
-    BBI = I;  // Don't invalidate iterator.
-    return true;
-  }
+  if (isa<ConstantInt>(MSI->getLength()) && !MSI->isVolatile())
+    if (Instruction *I = tryMergingIntoMemset(MSI, MSI->getDest(),
+                                              MSI->getValue())) {
+      BBI = I;  // Don't invalidate iterator.
+      return true;
+    }
   return false;
 }