[PATCH] D128877: [LoopCacheAnalysis] Fix a type mismatch bug in cost calculation
Congzhe Cao via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 29 22:27:49 PDT 2022
congzhe created this revision.
Herald added subscribers: javed.absar, hiraditya, nemanjai.
Herald added a project: All.
congzhe requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
As reported in https://reviews.llvm.org/rGb941857b40edd7f3f3a9ec2ec85a26db24739774#1100674, there is a loop cache analysis bug exposed by the recent loop interchange new cost model patch. In `isConsecutive()` from LoopCacheAnalysis.cpp, sometimes the SCEV variables `Coeff` and `ElemSize` may not match, e.g., when there is no target datalayout provided in an IR. The mismatch would cause SCEV failures when multiplying `Coeff` 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. The IR reported in https://reviews.llvm.org/rGb941857b40edd7f3f3a9ec2ec85a26db24739774#1100674 is added in loop cache analysis tests.
As a clean-up, the `Stride` variable in `computeRefCost()` has been already computed in `isConsecutive()`, so I remove the duplicate calculations of `Stride` which also helps this patch to be more compact.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D128877
Files:
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128877.441258.patch
Type: text/x-patch
Size: 7091 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220630/d00abf28/attachment.bin>
More information about the llvm-commits
mailing list