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

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 30 06:57:01 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();
 
----------------
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...


================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:8047
+  const SCEV *One = getOne(ExitCountType);
+  if (!Extend || willNotOverflow(Instruction::Add, false, ExitCount, One))
+    return getAddExpr(ExitCount, One);
----------------
I'd prefer this to go back to the previous version. willNotOverflow() is very expensive and not needed here.


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