[all-commits] [llvm/llvm-project] e20917: [SimplifyIndVar] LCSSA form is destroyed by simpli...

Vedant Paranjape via All-commits all-commits at lists.llvm.org
Wed Feb 21 04:22:09 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e209178d6402348414b69941c77d621919b3b7ab
      https://github.com/llvm/llvm-project/commit/e209178d6402348414b69941c77d621919b3b7ab
  Author: Vedant Paranjape <vedant.paranjape at amd.com>
  Date:   2024-02-21 (Wed, 21 Feb 2024)

  Changed paths:
    M llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
    A llvm/test/Transforms/LoopUnroll/gh-issue77118-broken-lcssa-form.ll

  Log Message:
  -----------
  [SimplifyIndVar] LCSSA form is destroyed by simplifyLoopIVs, preserve it (#78696)

In LoopUnroll, peelLoop is called on the loop. After the loop is peeled
it calls simplifyLoopAfterUnroll on the loop. This call to
simplifyLoopAfterUnroll doesn't preserve the LCSSA form of the parent
loop and thus during the next call to peelLoop the LCSSA form is already
broken.

LoopPeel util takes in the PreserveLCSSA argument and it passes
on the same argument to simplifyLoop which checks if the loop is in a
valid LCSSA form, when (PreserveLCSSA = true).

This causes an assert in simplifyLoop when (PreserveLCSSA = true), as
during the last call LCSSA for the loop wasn't preserved, and thus
crashes at the following assert.

assert(L->isRecursivelyLCSSAForm(*DT, *LI) &&
            "Requested to preserve LCSSA, but it's already broken.");

Upon debugging, it is evident that simplifyLoopIVs call inside
simplifyLoopAfterUnroll breaks the LCSSA form. This patch fixes
llvm#77118, it checks if the replacement of IV Users with Loop Invariant
preserves the LCSSA form. If it does not, it emits the required LCSSA
Phi instructions.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list