Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VP][LV] Migrate vector predication pass and intrinsics from llvm-bpevl. #65

Merged
merged 4 commits into from
Mar 11, 2024

Conversation

AinsleySnow
Copy link

@AinsleySnow AinsleySnow commented Mar 8, 2024

This patch migrate two commit implementing the vector predication pass from LLVM bpEVL.

The two commits is based on the loop vectorizer one year ago, but now details of loop vectorizer changed and some code in these commits must be changed accordingly.

Modification to VPIntrinsics.def introduced by bpevl is dropped, because #66199 already added the same defination.

D158779 simplified the logic of addCanonicalIVRecipes, and move part of its code to addVPLaneMaskPhiAndUpdateExitBranch. Since the first commit has something to do with the moved logic, I modified the prototype of addActiveLaneMask, addVPLaneMaskPhiAndUpdateExitBranch and let addCanonicalIVRecipes return NextEVL to make sure NextEVL is insert to the exiting block as in the origin commit.

D147964 deleted the loop for setting TripCount in the start of VPlan::prepareToExecute (VPlan.cpp, line 616-621), therefore code in the first commit accessing trip count through State.get (example) will get undesired result and eventually crash the program. So I modified the code to get TripCount stored in the recipes directly (VPlanRecipes.cpp, line 1829 and VPlanRecipes.cpp, line 447).

#74761 remove the CanonicalIVIncrement VPInstruction (link) and use add instruction instead but part of the logic of the first commit relies on it. So I modified the processing logic of binary operator (VPlan.cpp, line 284-295) to add them.

Finally I updated vp_intrinsics.ll. The changes are likely introduced by other changes of LV but not by mistakes in migration.

loralb and others added 4 commits March 8, 2024 10:39
Add new VP Recipes for the Explicit Vector Length (EVL) and add support
for VP memory intrinsics (vp.load, vp.store, vp.gather, vp.scatter).
This pass transforms full-length vector instructions or intrinsics calls
to VP ones by recovering the (mask,evl) information from one of the
memory writing VP operations and backpropagating it.
@AinsleySnow
Copy link
Author

AinsleySnow commented Mar 8, 2024

The following tests crashed in my environment:

  Clang :: Driver/baremetal.cpp
  Clang :: Driver/csky-toolchain.c
  Clang :: Driver/freebsd-include-paths.c
  Clang :: Driver/haiku.c
  Clang :: Driver/hexagon-toolchain-linux.c
  Clang :: Driver/riscv32-toolchain-extra.c
  Clang :: Driver/riscv64-toolchain-extra.c
  Clang :: Driver/solaris-ld.c
  Clang :: Modules/embed-files-compressed.cpp
  Clang :: OpenMP/declare_variant_device_isa_codegen_1.c
  LLVM :: CodeGen/Generic/live-debug-label.ll

But they still crash even without this patch. Maybe we need a ci to run the tests, just like what we do in ruyisdk.

@ChunyuLiao ChunyuLiao merged commit e009baa into plctlab:auto-vector-upstream-next Mar 11, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants