[PATCH] Refactor code for adding runtime checks in vectorizer.

Michael Zolotukhin mzolotukhin at apple.com
Tue May 26 14:38:12 PDT 2015


Hi Hal,

The thing is that `VectorPH` already exists in the original code. Actually, the main points of this patch was to make this blocks structure more apparent - rather than having `BypassBlock`, `LastBypassBlock`, `VectorPH` and others, I'd prefer to have only `VectorPH`.

Another issue that I tried to solve here is the following. When we add a new runtime check in the original code, we

1. Add instructions for new check to the basic block with previous check. E.g.:

  std::tie(FirstCheckInst, MemRuntimeCheck) = Legal->getLAI()->addRuntimeCheck(LastBypassBlock->getTerminator());

2. `LastBypassBlock` now contains instructions for both previous and new check. Split it:

  BasicBlock *CheckBlock = LastBypassBlock->splitBasicBlock(FirstCheckInst, "vector.memcheck");

3. Add a branch instruction based on the *previous* check:

  Instruction *OldTerm = LastBypassBlock->getTerminator();
  BranchInst::Create(MiddleBlock, CheckBlock, Cmp, OldTerm);
  OldTerm->eraseFromParent();



4. Save the *current* check - it will be used for creating branch when we create a *next* check.

  Cmp = StrideCheck;

So, I tried to remove this dependency between different checks and make code responsible for generation a single check self-dependent and isolated.

PS: I'm fine with renaming `VectorPH` to `VectorPreHeader`, I'll do that along with rebasing on top of the trunk.


http://reviews.llvm.org/D9332

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list