[all-commits] [llvm/llvm-project] 982da7: [SCEVExpander] Stop hoisting IR when reusing phis

Philip Reames via All-commits all-commits at lists.llvm.org
Tue Aug 17 09:38:48 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 982da7a20c406c5725b5fe20d699a78069e54ffa
      https://github.com/llvm/llvm-project/commit/982da7a20c406c5725b5fe20d699a78069e54ffa
  Author: Philip Reames <listmail at philipreames.com>
  Date:   2021-08-17 (Tue, 17 Aug 2021)

  Changed paths:
    M llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h
    M llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
    A llvm/test/Transforms/LoopStrengthReduce/wrong-hoisting-iv.ll

  Log Message:
  -----------
  [SCEVExpander] Stop hoisting IR when reusing phis

his is a fix for PR43678, and is an alternate patch to D105723.

The basic issue we're running into is that LSR + SCEVExpander are moving the very instruction whose operand we're in the process of expanding. This breaks the subtle and ill-documented invariant which let LSR work. (Full story can be found here: https://reviews.llvm.org/D105723#2878473)

Rather than attempting a fix, this change just removes the optimization entirely. The code is entirely untested, and removing it appears to have no impact I can find.  This code was added back in 2014 by 1e12f8563d4b7 with a single test which does not seem to actually test the hoisting logic.

>From a philosophical standpoint, it also seems very strange to have the expander implementing optimizations which should live in a dedicated transform pass.

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




More information about the All-commits mailing list