[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
Fri Sep 15 16:35:10 PDT 2017
sanjoy requested changes to this revision.
sanjoy added inline comments.
This revision now requires changes to proceed.
================
Comment at: lib/Analysis/ScalarEvolution.cpp:2347
+ for (unsigned i=Idx; i<Ops.size() && Ops[i]->getSCEVType() <= scMulExpr; ++i) {
+ if (isa<SCEVTruncateExpr>(Ops[i])) {
+ return cast<SCEVTruncateExpr>(Ops[i]);
----------------
This is doing a bit more work than it needs to -- if the first element after a constant isn't a trunc, then none of them are.
================
Comment at: lib/Analysis/ScalarEvolution.cpp:2366
+ };
+ if (const auto *Trunc = FindTrunc()) {
Type *DstType = Trunc->getType();
----------------
Instead of searching from a trunc operation and going from there, how about phrasing this logic as:
1. First figure out the SrcType, if possible (by looking at truncates and multiplies)
2. If (1) was successful, re-traverse the operands and try to do the trunc extraction
This makes it clear that the second part is only using SrcType and not the whole truncate.
https://reviews.llvm.org/D37888
More information about the llvm-commits
mailing list