[llvm] r217344 - Add an AlignmentFromAssumptions Pass

Andrew Trick atrick at apple.com
Sun Sep 7 15:29:41 PDT 2014


> On Sep 7, 2014, at 1:05 PM, Hal Finkel <hfinkel at anl.gov> wrote:
> 
> +// Given an expression for the (constant) alignment, AlignSCEV, and an
> +// expression for the displacement between a pointer and the aligned address,
> +// DiffSCEV, compute the alignment of the displaced pointer if it can be
> +// reduced to a constant.
> +static unsigned getNewAlignmentDiff(const SCEV *DiffSCEV,
> +                                    const SCEV *AlignSCEV,
> +                                    ScalarEvolution *SE) {
> +  // DiffUnits = Diff % int64_t(Alignment)
> +  const SCEV *DiffAlignDiv = SE->getUDivExpr(DiffSCEV, AlignSCEV);
> +  const SCEV *DiffAlign = SE->getMulExpr(DiffAlignDiv, AlignSCEV);
> +  const SCEV *DiffUnitsSCEV = SE->getMinusSCEV(DiffAlign, DiffSCEV);
> +
> +  DEBUG(dbgs() << "\talignment relative to " << *AlignSCEV << " is " <<
> +                  *DiffUnitsSCEV << " (diff: " << *DiffSCEV << ")\n");
> +
> +  if (const SCEVConstant *ConstDUSCEV =
> +      dyn_cast<SCEVConstant>(DiffUnitsSCEV)) {
> +    int64_t DiffUnits = ConstDUSCEV->getValue()->getSExtValue();

Hi Hal,

One thing I didn’t understand after reviewing this is how DIffUnitsSCEV can be constant if either DiffSCEV or AlignSCEV are nonconstant. Are you ever seeing that case? If so, can you post SCEVs that you’re seeing so I can understand and we can add comments?

-Andy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140907/15b922d8/attachment.html>


More information about the llvm-commits mailing list