Computing with Scalar evolution


I have just started using the ScalarEvolution class but I am now sure how to perform a computation with the expression.

Specifically, I use ScalarEvolution to get the getSymbolicMaxBackedgeTakenCount() of a particular loop. Is there a way I can provide the resultant expression with the number of iterations and the input of the operands in order to get the final value of the expression?

As an example, if I get the final resultant SCEV as:
(-5 + (5 smax (1 + %K)))

Is there a way for me to input the value of K and get the final (integer) value of this expression?

Thanks in advance!

Hi @rrayan, there is a great tutorial talk from a previous LLVM dev meeting that might be of use. I found it very helpful when trying to understand SCEVs 2018 EuroLLVM Developers’ Meeting: J. Absar “Scalar Evolution - Demystified”

1 Like