[LoopCacheAnalysis] Fix a type mismatch problem in cost calculation
authorCongzhe Cao <congzhe.cao@huawei.com>
Thu, 21 Jul 2022 05:35:58 +0000 (01:35 -0400)
committerCongzheUalberta <congzhecao@gmail.com>
Thu, 21 Jul 2022 05:57:05 +0000 (01:57 -0400)
commit05ccde8023a6176927454f478730d29e53104c05
tree0840e81077e3549e0fe8e566a82daf8727973b8f
parent61fa7a88c7b6360222d4107e938529f2dccc1176
[LoopCacheAnalysis] Fix a type mismatch problem in cost calculation

There is a problem in loop cache analysis that the types of SCEV variables
`Coeff` and `ElemSize` in function `isConsecutive()` may not match. The
mismatch would cause SCEV failures when `Coeff` is multiplied with `ElemSize`.

The fix in this patch is to extend the type of both `Coeff` and `ElemSize` to
whichever is wider in those two variables. As a clean-up, duplicate calculations
of `Stride` in `computeRefCost()` is then removed.

Reviewed By: Meinersbur, #loopoptwg

Differential Revision: https://reviews.llvm.org/D128877
llvm/include/llvm/Analysis/LoopCacheAnalysis.h
llvm/lib/Analysis/LoopCacheAnalysis.cpp
llvm/test/Analysis/LoopCacheAnalysis/PowerPC/compute-cost.ll
llvm/test/Analysis/LoopCacheAnalysis/compute-cost.ll