[PATCH] D27518: Moving isComplex decision to TTI

Michael Kuperstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 29 10:12:04 PST 2016


mkuper added inline comments.


================
Comment at: include/llvm/Analysis/TargetTransformInfo.h:26
 #include "llvm/ADT/Optional.h"
+#include "llvm/Analysis/ScalarEvolutionExpander.h"
+#include "llvm/Analysis/ScalarEvolutionExpressions.h"
----------------
mkuper wrote:
> Why do you need the expander?
Sorry, I missed this on the previous pass - but why do you even need this include here at all?
Can you forward-declare what you need (SCEV, ScalarEvolution?) and actually include this where you need it (I guess TargetTransformInfoImpl.h and the relevant cpps)?


================
Comment at: include/llvm/Analysis/TargetTransformInfoImpl.h:446
+      return false;
+    APInt StrideVal = cast<SCEVConstant>(Step)->getAPInt();
+    if (StrideVal.getBitWidth() > 64)
----------------
You could just return a SCEVConstant* from getConstantStrideStep()
E.g. something like:


```
  const SCEVConstant *getConstantStrideStep(ScalarEvolution *SE, const SCEV *Ptr) {
    if (!isStridedAccess(Ptr))
      return nullptr;

    const SCEVAddRecExpr *AddRec = cast<SCEVAddRecExpr>(Ptr);
    return dyn_cast<SCEVConstant>(AddRec->getStepRecurrence(*SE));
  }
```

Then this code could be something like:

```
bool isConstantStridedAccessLessThan(ScalarEvolution *SE, const SCEV *Ptr,
                                     int64_t MergeDistance) {
  const SCEVConstant *Step = getConstantStrideStep(SE, Ptr);
  APInt StrideVal = Step->getAPInt();
  if (StrideVal.getBitWidth() > 64)
    return false;
  return StrideVal.getSExtValue() < MergeDistance;
}
```



https://reviews.llvm.org/D27518





More information about the llvm-commits mailing list