Resources on SCEV and LoopInfo

Are there any tutorials/examples on usages of SCEV and/or LoopInfo? I know i can look up the source but i was thinking of something more contrived perhaps, to get some introduction on how to use/apply the APIs.

Ees

Hi Ees,

Not sure if you’ve seen it, but there’s a SCEV tutorial from euro llvm https://www.youtube.com/watch?v=AmjliNp0_00&ab_channel=LLVM

Hi Ees,

Just to be sure: I understand that you are not looking for a tutorial on the theoretical aspect
of how SCEV / LoopInfo work or what they try to do (e.g. what does the {0,+,1} mean or
how loops are identified etc.). If you’re looking for those too, please let me know.

So, IIUC, you are looking for examples on how to use the APIs. There are very good real-world examples here and there
but you’d have to understand the context. For example, DependenceAnalysis has very clear usage
of both (especially SCEV). But you’d have to care for DA or to know its background already so that you
understand what it tries to do with SCEV. If you’re interested in such examples, let me know.

If you’re not, I would propose that you get a clone of LLVM and create
a dummy pass (e.g. like this: https://github.com/baziotis/llvm-project/commit/fdd94be9c266e5d3eb39d4b9f1362b5f7837a59a, ignore
any of my naming, you can concentrate only in the ::run() function) and just experiment.

That is, get LoopInfo analysis results, loop over the loops, get preheaders, get latches, etc. Then also,
iterate over code, find pointers, try to getSCEV() them. Then try to also getSCEVAtScope(). Try to get the steps, starts, exit count,
evaluateAtIteration() etc. Furthermore, see the different kinds of expressions, recurse at the expr tree, inspect the wrap flags.

The list goes on and on… It depends on what you’re interested in. As you’re experimenting, if something is not clear,
you can always ask in llvm-dev.

Best,
Stefanos

Στις Τρί, 13 Οκτ 2020 στις 12:16 μ.μ., ο/η Ees via llvm-dev <llvm-dev@lists.llvm.org> έγραψε: