[PATCH] D71569: [LoopFusion] Ensure that both loops are guarded or neither are guarded.

Shixiong Xu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 11 07:05:59 PST 2021


xusx595 added a comment.

I wonder if this issue still exists in llvm trunk.

  // Ensure that FC0 and FC1 have identical guards.
  // If one (or both) are not guarded, this check is not necessary.
  if (FC0->GuardBranch && FC1->GuardBranch &&
      !haveIdenticalGuards(*FC0, *FC1) && !TCDifference) {
    LLVM_DEBUG(dbgs() << "Fusion candidates do not have identical "
                         "guards. Not Fusing.\n");
    reportLoopFusion<OptimizationRemarkMissed>(*FC0, *FC1,
                                               NonIdenticalGuards);
    continue;
  }
  
  if (!isSafeToMoveBefore(*FC1->Preheader,
                          *FC0->Preheader->getTerminator(), DT, &PDT,
                          &DI)) {
    LLVM_DEBUG(dbgs() << "Fusion candidate contains unsafe "
                         "instructions in preheader. Not fusing.\n");
    reportLoopFusion<OptimizationRemarkMissed>(*FC0, *FC1,
                                               NonEmptyPreheader);
    continue;
  }
  
  if (FC0->GuardBranch) {
    assert(FC1->GuardBranch && "Expecting valid FC1 guard branch");

It seems we still need add checks to make sure both loops are guarded or neither are guarded. I enabled loop fusion in our compiler for Xtensa at Cadence, and encountered this issue (our llvm base is 10.0.1 at the moment).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71569



More information about the llvm-commits mailing list