polly::SCEVValidator extends the notion of ScalarEvolution values by allowing SDiv and SRem instructions in them. These are handled by polly::SCEVAffinator, but not by llvm::SCEVExpander. SCEVExpander instead references the original values that might be defined only afterwards.
This patch is a workaround by copying those referenceable SDivs/SRems to the polly.start block where the SCEV is expanded and can use the copied instructions. This pessimistically copies values even if not used by any SCoP parameter to avoid making SCEVExpander generate illegal code and recursivity.
Ideally, one introduces SCEVSDiv and SCEVSRem classes to get rid of this and other such workarounds in Polly.
Why do we need this?