[all-commits] [llvm/llvm-project] fc539b: [SCEV] Infer ranges for SCC consisting of cycled Phis

Max Kazantsev via All-commits all-commits at lists.llvm.org
Thu Feb 17 03:04:09 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: fc539b0004d4fe8072aca00e38599a2300a955ce
      https://github.com/llvm/llvm-project/commit/fc539b0004d4fe8072aca00e38599a2300a955ce
  Author: Max Kazantsev <mkazantsev at azul.com>
  Date:   2022-02-17 (Thu, 17 Feb 2022)

  Changed paths:
    M llvm/include/llvm/Analysis/ScalarEvolution.h
    M llvm/lib/Analysis/ScalarEvolution.cpp
    M llvm/test/Analysis/ScalarEvolution/cycled_phis.ll
    M llvm/test/Analysis/ScalarEvolution/unknown_phis.ll

  Log Message:
  -----------
  [SCEV] Infer ranges for SCC consisting of cycled Phis

Our current strategy of computing ranges of SCEVUnknown Phis was to simply
compute the union of ranges of all its inputs. In order to avoid infinite recursion,
we mark Phis as pending and conservatively return full set for them. As result,
even simplest patterns of cycled phis always have a range of full set.

This patch makes this logic a bit smarter. We basically do the same, but instead
of taking inputs of single Phi we find its strongly connected component (SCC)
and compute the union of all inputs that come into this SCC from outside.

Processing entire SCC together has one more advantage: we can set range for all
of them at once, because the only thing that happens to them is the same value is
being passed between those Phis. So, despite we spend more time analyzing a
single Phi, overall we may save time by not processing other SCC members, so
amortized compile time spent should be approximately the same.

Differential Revision: https://reviews.llvm.org/D110620
Reviewed By: reames




More information about the All-commits mailing list