[all-commits] [llvm/llvm-project] 607127: [IndVars] Teach replaceCongruentIVs to avoid scram...

Eli Friedman via All-commits all-commits at lists.llvm.org
Wed Jul 12 12:28:07 PDT 2023

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 60712732ea2442375cccef3eb87784a3a3888fad
  Author: Eli Friedman <efriedma at quicinc.com>
  Date:   2023-07-12 (Wed, 12 Jul 2023)

  Changed paths:
    M llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
    M llvm/test/Transforms/IndVarSimplify/AArch64/widen-loop-comp.ll

  Log Message:
  [IndVars] Teach replaceCongruentIVs to avoid scrambling induction variables

replaceCongruentIVs analysis is based on ScalarEvolution; this makes
comparing different PHIs and performing the replacement straightforward.
However, it can have some side-effects: it isn't aware whether an
induction variable is in canonical form, so it can perform replacements
which obscure the meaning of the IR.

In test22 in widen-loop-comp.ll, the resulting loop can't be analyzed by
ScalarEvolution at all.

My attempted solution is to restrict the transform: don't try to replace
induction variables using PHI nodes that don't represent simple
induction variables.

I'm not sure if this is the best solution; suggestions welcome.

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

More information about the All-commits mailing list