[all-commits] [llvm/llvm-project] c70f0b: [SCEVExpander] Avoid re-using existing casts if it...

Florian Hahn via All-commits all-commits at lists.llvm.org
Sun Aug 9 05:27:33 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: c70f0b9d4a063df396bb63378963cedbaa357bb8
      https://github.com/llvm/llvm-project/commit/c70f0b9d4a063df396bb63378963cedbaa357bb8
  Author: Florian Hahn <flo at fhahn.com>
  Date:   2020-08-09 (Sun, 09 Aug 2020)

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

  Log Message:
  -----------
  [SCEVExpander] Avoid re-using existing casts if it means updating users.

Currently the SCEVExpander tries to re-use existing casts, even if they
are not exactly at the insertion point it was asked to create the cast.
To do so in some case, it creates a new cast at the insertion point and
updates all users to use the new cast.

This behavior is problematic, because it changes the IR outside of the
instructions created during the expansion. Therefore we cannot
completely undo all changes made during expansion.

This re-use should be only an extra optimization, so only using the new
cast in the expanded instructions should not be a correctness issue.
There are many cases equivalent instructions are created during
expansion.

This patch also adjusts findInsertPointAfter to skip instructions
inserted during expansion. This enables re-using existing casts without
the renaming any uses, by picking a better insertion point.

Reviewed By: efriedma, lebedev.ri

Differential Revision: https://reviews.llvm.org/D84399




More information about the All-commits mailing list