[PATCH] D66084: Remove asserts in getLoopGuardBranch

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 12 01:07:56 PDT 2019


fhahn requested changes to this revision.
fhahn added a comment.
This revision now requires changes to proceed.

Sorry for not being more clear. I meant we need a test where the latch is not exiting, which without this patch will assert and with this patch will return nullptr. So please add a test for something like

  +TEST(LoopInfoTest, LatchNotExiting) {
  +  const char *ModuleStr =
  +      "define void @foo(i32* %A, i32 %ub) {\n"
  +      "entry:\n"
  +      "  %guardcmp = icmp slt i32 0, %ub\n"
  +      "  br i1 %guardcmp, label %for.preheader, label %for.end\n"
  +      "for.preheader:\n"
  +      "  br label %for.body\n"
  +      "for.body:\n"
  +      "  %i = phi i32 [ 0, %for.preheader ], [ %inc, %for.body ]\n"
  +      "  %aux = phi i32 [ 0, %for.preheader ], [ %auxinc, %for.body ]\n"
  +      "  %loopvariant = phi i32 [ 0, %for.preheader ], [ %loopvariantinc, %for.body ]\n"
  +      "  %usedoutside = phi i32 [ 0, %for.preheader ], [ %usedoutsideinc, %for.body ]\n"
  +      "  %mulopcode = phi i32 [ 0, %for.preheader ], [ %mulopcodeinc, %for.body ]\n"
  +      "  %idxprom = sext i32 %i to i64\n"
  +      "  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %idxprom\n"
  +      "  store i32 %i, i32* %arrayidx, align 4\n"
  +      "  %mulopcodeinc = mul nsw i32 %mulopcode, 5\n"
  +      "  %usedoutsideinc = add nsw i32 %usedoutside, 5\n"
  +      "  %loopvariantinc = add nsw i32 %loopvariant, %i\n"
  +      "  %auxinc = add nsw i32 %aux, 5\n"
  +      "  %inc = add nsw i32 %i, 1\n"
  +      "  %cmp = icmp slt i32 %inc, %ub\n"
  +      "  br i1 %cmp, label %for.latch, label %for.exit\n"
  +      "for.latch:\n"
  +      "  br label %for.body\n"
  +      "for.exit:\n"
  +      "  %lcssa = phi i32 [ %usedoutside, %for.body ]\n"
  +      "  br label %for.end\n"
  +      "for.end:\n"
  +      "  ret void\n"
  +      "}\n";
  +
  +  // Parse the module.
  +  LLVMContext Context;
  +  std::unique_ptr<Module> M = makeLLVMModule(Context, ModuleStr);
  +
  +  runWithLoopInfoPlus(
  +      *M, "foo",
  +      [&](Function &F, LoopInfo &LI, ScalarEvolution &SE) { /* Add checks */ }


Repository:
  rL LLVM

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

https://reviews.llvm.org/D66084





More information about the llvm-commits mailing list