[PATCH] D73181: [SCEV] Do not use backedge SCEV of PHI if its input is another PHI

Denis Antrushin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 23 02:00:35 PST 2020


dantrushin marked 6 inline comments as done.
dantrushin added inline comments.


================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:8246
+            const SCEV *OnBackedge = getSCEV(BackedgeVal);
+            if (!isa<PHINode>(BackedgeVal) &&
+                IsAvailableOnEntry(LI, DT, OnBackedge, PN->getParent()))
----------------
mkazantsev wrote:
> Your check is overprotective. If `BackedgeVal` is a Phi from another loop than PN's (e.g. outer loop or some other loop going before it), it is OK to use it as exit value. The problem only happens if `PN->getLoop() == BackedgeVal->getLoop()`, am I correct?
You're right.
I've been cutting edges to keep code cleaner ;)


================
Comment at: llvm/test/Analysis/ScalarEvolution/pr44605.ll:46
+  %local_3_31 = mul i32 %local_4_5.pn, %.udiv
+  %0 = mul i32 %local_7_3, %.udiv
+  %1 = sub i32 %0, %local_3_4
----------------
mkazantsev wrote:
> Does the test really need all these computations inside? It's tad too much code, not clear what of it is important. If you can reduce the test please do.
Yes. They all needed to outsmart LLVM and make it execute this code.
All that matters in fact, are just two PHIs, %local_6_6 and %local_3_4 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73181





More information about the llvm-commits mailing list