From f897d087d09dbbccec3417f812109ed534b94248 Mon Sep 17 00:00:00 2001 From: Rachel Craik Date: Fri, 15 Nov 2019 14:56:26 -0500 Subject: [LoopCacheAnalysis]: Fix assertion failure during cost computation Ensure the stride and trip count have the same type before multiplying them during reference cost calculation Reviewed By: jdoefert Differential Revision: https://reviews.llvm.org/D70192 --- llvm/lib/Analysis/LoopCacheAnalysis.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'llvm/lib') diff --git a/llvm/lib/Analysis/LoopCacheAnalysis.cpp b/llvm/lib/Analysis/LoopCacheAnalysis.cpp index 098bc6f6818..25325ec1be0 100644 --- a/llvm/lib/Analysis/LoopCacheAnalysis.cpp +++ b/llvm/lib/Analysis/LoopCacheAnalysis.cpp @@ -284,6 +284,9 @@ CacheCostTy IndexedReference::computeRefCost(const Loop &L, const SCEV *ElemSize = Sizes.back(); const SCEV *Stride = SE.getMulExpr(Coeff, ElemSize); const SCEV *CacheLineSize = SE.getConstant(Stride->getType(), CLS); + Type *WiderType = SE.getWiderType(Stride->getType(), TripCount->getType()); + Stride = SE.getNoopOrSignExtend(Stride, WiderType); + TripCount = SE.getNoopOrAnyExtend(TripCount, WiderType); const SCEV *Numerator = SE.getMulExpr(Stride, TripCount); RefCost = SE.getUDivExpr(Numerator, CacheLineSize); LLVM_DEBUG(dbgs().indent(4) -- cgit v1.2.3