[PATCH] D84399: [SCEVExpander] Avoid re-sing existing casts if it means updating users.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 28 04:12:39 PDT 2020


fhahn updated this revision to Diff 281182.
fhahn added a comment.

Adjust code to allow for better re-use inserted values with the following changes:

1. Update findInsertPointAfter to skip inserted instructions. This ensures we can straight-forwardly re-use inserted instructions for expanding the same value multiple times. There's no documentation of the intended behavior of the function, but from the name and uses, we are looking for an insertion pointer after the given instruction, which new code does.

2. Adjust ReuseOrCreateCast to re-use the first suitable cast that locally comes before the requested IP. This should return a suitable cast, while allowing re-using already inserted instructions. It also simplifies the logic. Now it is clear that we either re-use an existing cast or create a new one outside the loop.

With those changes, the regression in the LoopDistribute test is gone.

Note that both changes mentioned above depend on each other to work together, so it is not possible to split them off.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84399/new/

https://reviews.llvm.org/D84399

Files:
  llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h
  llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
  llvm/test/Transforms/LoopDistribute/bounds-expansion-bug.ll
  llvm/test/Transforms/LoopIdiom/reuse-cast.ll
  llvm/test/Transforms/LoopStrengthReduce/pr27056.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84399.281182.patch
Type: text/x-patch
Size: 6208 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200728/280e6e50/attachment.bin>


More information about the llvm-commits mailing list