[PATCH] D147117: [SCEV] When computing trip count, only zext if necessary

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 31 01:30:20 PDT 2023


nikic added inline comments.


================
Comment at: llvm/lib/Analysis/LoopCacheAnalysis.cpp:337
   if (auto ConstantCost = dyn_cast<SCEVConstant>(RefCost))
-    return ConstantCost->getValue()->getSExtValue();
+    return ConstantCost->getValue()->getZExtValue();
 
----------------
caojoshua wrote:
> nikic wrote:
> > The changes to LoopCacheAnalysis should be split out into a separate patch. I'm also wondering why this changes some but not all of the AnyExtends...
> The places where I changed sext->zext are SCEVs that are computed from TripCount. In this case, RefCost is set to TripCount in the else block above.
> 
> I thought it made sense to have a single patch for these two changes. It would be harder to motivate the changes if I only submitted a patch for LoopCacheAnalysis. And the whole patch is small overall, so its not hard to read.
But aren't the two AnyExtends in the `else` block above also on trip counts?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147117/new/

https://reviews.llvm.org/D147117



More information about the llvm-commits mailing list