[PATCH] D37888: [SCEV] Generalize folding of trunc(x)+n*trunc(y) into folding m*trunc(x)+n*trunc(y)

Sanjoy Das via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 20 16:41:03 PDT 2017


sanjoy added inline comments.


================
Comment at: lib/Analysis/ScalarEvolution.cpp:2350
+      return T->getOperand()->getType();
+    for (unsigned i = Idx; i < Ops.size() && isa<SCEVMulExpr>(Ops[i]); ++i) {
+      const auto *Mul = cast<SCEVMulExpr>(Ops[i]);
----------------
I think this can just be:

```
if (auto *Mul = dyn_cast<SCEVMulExpr>(Ops[Idx]))
  if (auto *Trunc = dyn_cast<SCEVTruncateExpr>(Mul->getOperand(Mul->getNumOperands() - 1)))
    return Trunc->getOperand()->getType();
return nullptr;
```

The reasoning being we don't need to worry about mul expressions with the last operand as a constant -- these should have been folded away.


https://reviews.llvm.org/D37888





More information about the llvm-commits mailing list