[PATCH] D12066: Introduce the ScopExpander as a SCEVExpander replacement

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 16 23:39:31 PDT 2015


jdoerfert added a comment.

Let me try to comment on both questions (by Hal as well as Sanjoy) at once.

@hfinkel regarding how we model these additions to SCEV:

We use SCEVs as an intermediate step from IR to isl expressions (more precicly isl piecewise affince functions [isl_pw_aff]). However, these piecewise affine functions can express things SCEVs cannot and vice versa. With SDiv and SRem (where the right hand side is a constant) we allowed Polly to represent more than SCEVs as piecewise affine functions. To this end we have to check the SCEVUnknowns each time and decide if they are parameters of the region we analyze (then we treat them as unknown values) or if we can model them. The latter is only supported for the SDiv and SRem at the moment but will be extended at some point to more (e.g. there is a patch that allows bitwise operations etc.).

@Sanjoy & @hfinkel regarding this patch and its purpose:

So far the modeling as described above was sufficent to represent SDiv and SRem operations in the mathematical model and to generate a new, optimized code from it. However, recently we noticed a bug in our code generation if the SDiv or SRem operation are part of a parameter that we assume to be copyable. That means we think we can just copy the (side effect free!) computation of the parameter in front of our optimized code version without worrying where the orginal computation was. But if there was a SDiv or SRem in the computation and these did not dominate the analyzed region but where part of it, we generated invalid code when we expanded the parameter SCEV in front of the optimized code region. It was invalid because it referenced the SDiv or SRem in the original region that did not dominate the optimized region. [Note that during our analysis we looked through the SDiv and SRem instruction but SCEVExpander stopped with them]. To this end we introduced the ScopExpander which will expand SCEVs as the SCEVExpander __but__ in case of SDiv or SRem instructions move the expansions in front of the SCoP and expand the SDiv or SRem there instead of just using the original instruction.


http://reviews.llvm.org/D12066





More information about the llvm-commits mailing list