Index: lib/Transforms/Vectorize/SLPVectorizer.cpp =================================================================== --- lib/Transforms/Vectorize/SLPVectorizer.cpp +++ lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -1616,16 +1616,22 @@ } case Instruction::Load: { // Cost of wide load - cost of scalar loads. + LoadInst *LoadI = cast(VL[0]); int ScalarLdCost = VecTy->getNumElements() * - TTI->getMemoryOpCost(Instruction::Load, ScalarTy, 1, 0); - int VecLdCost = TTI->getMemoryOpCost(Instruction::Load, VecTy, 1, 0); + TTI->getMemoryOpCost(Instruction::Load, ScalarTy, + LoadI->getAlignment(), 0); + int VecLdCost = TTI->getMemoryOpCost(Instruction::Load, VecTy, + LoadI->getAlignment(), 0); return VecLdCost - ScalarLdCost; } case Instruction::Store: { // We know that we can merge the stores. Calculate the cost. + StoreInst *StoreI = cast(VL[0]); int ScalarStCost = VecTy->getNumElements() * - TTI->getMemoryOpCost(Instruction::Store, ScalarTy, 1, 0); - int VecStCost = TTI->getMemoryOpCost(Instruction::Store, VecTy, 1, 0); + TTI->getMemoryOpCost(Instruction::Store, ScalarTy, + StoreI->getAlignment(), 0); + int VecStCost = TTI->getMemoryOpCost(Instruction::Store, VecTy, + StoreI->getAlignment(), 0); return VecStCost - ScalarStCost; } case Instruction::Call: {