[all-commits] [llvm/llvm-project] 48cc92: Reapply "[SLP] Schedule only sub-graph of vectoriz...

Philip Reames via All-commits all-commits at lists.llvm.org
Fri Mar 25 10:44:12 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 48cc9287f55544f336fd4620c19b42b1d5266bfb
      https://github.com/llvm/llvm-project/commit/48cc9287f55544f336fd4620c19b42b1d5266bfb
  Author: Philip Reames <listmail at philipreames.com>
  Date:   2022-03-25 (Fri, 25 Mar 2022)

  Changed paths:
    M llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
    M llvm/test/Transforms/SLPVectorizer/AArch64/64-bit-vector.ll
    M llvm/test/Transforms/SLPVectorizer/AArch64/horizontal.ll
    M llvm/test/Transforms/SLPVectorizer/AArch64/loadi8.ll
    M llvm/test/Transforms/SLPVectorizer/AArch64/matmul.ll
    M llvm/test/Transforms/SLPVectorizer/AArch64/memory-runtime-checks.ll
    M llvm/test/Transforms/SLPVectorizer/AArch64/sdiv-pow2.ll
    M llvm/test/Transforms/SLPVectorizer/AArch64/slp-and-reduction.ll
    M llvm/test/Transforms/SLPVectorizer/AArch64/slp-or-reduction.ll
    M llvm/test/Transforms/SLPVectorizer/AArch64/slp-xor-reduction.ll
    M llvm/test/Transforms/SLPVectorizer/AArch64/spillcost-di.ll
    M llvm/test/Transforms/SLPVectorizer/AArch64/spillcost-order.ll
    M llvm/test/Transforms/SLPVectorizer/AArch64/transpose-inseltpoison.ll
    M llvm/test/Transforms/SLPVectorizer/AArch64/transpose.ll
    M llvm/test/Transforms/SLPVectorizer/AArch64/tsc-s352.ll
    M llvm/test/Transforms/SLPVectorizer/AArch64/widen.ll
    M llvm/test/Transforms/SLPVectorizer/AMDGPU/packed-math.ll
    M llvm/test/Transforms/SLPVectorizer/NVPTX/v2f16.ll
    M llvm/test/Transforms/SLPVectorizer/SystemZ/pr34619.ll
    M llvm/test/Transforms/SLPVectorizer/X86/PR32086.ll
    M llvm/test/Transforms/SLPVectorizer/X86/addsub.ll
    M llvm/test/Transforms/SLPVectorizer/X86/align.ll
    M llvm/test/Transforms/SLPVectorizer/X86/arith-abs.ll
    M llvm/test/Transforms/SLPVectorizer/X86/arith-add-ssat.ll
    M llvm/test/Transforms/SLPVectorizer/X86/arith-add-usat.ll
    M llvm/test/Transforms/SLPVectorizer/X86/arith-add.ll
    M llvm/test/Transforms/SLPVectorizer/X86/arith-div.ll
    M llvm/test/Transforms/SLPVectorizer/X86/arith-fix.ll
    M llvm/test/Transforms/SLPVectorizer/X86/arith-mul.ll
    M llvm/test/Transforms/SLPVectorizer/X86/arith-smax.ll
    M llvm/test/Transforms/SLPVectorizer/X86/arith-smin.ll
    M llvm/test/Transforms/SLPVectorizer/X86/arith-sub-ssat.ll
    M llvm/test/Transforms/SLPVectorizer/X86/arith-sub-usat.ll
    M llvm/test/Transforms/SLPVectorizer/X86/arith-sub.ll
    M llvm/test/Transforms/SLPVectorizer/X86/arith-umax.ll
    M llvm/test/Transforms/SLPVectorizer/X86/arith-umin.ll
    M llvm/test/Transforms/SLPVectorizer/X86/bitreverse.ll
    M llvm/test/Transforms/SLPVectorizer/X86/bottom-to-top-reorder.ll
    M llvm/test/Transforms/SLPVectorizer/X86/broadcast.ll
    M llvm/test/Transforms/SLPVectorizer/X86/bswap.ll
    M llvm/test/Transforms/SLPVectorizer/X86/combined-stores-chains.ll
    M llvm/test/Transforms/SLPVectorizer/X86/consecutive-access.ll
    M llvm/test/Transforms/SLPVectorizer/X86/continue_vectorizing.ll
    M llvm/test/Transforms/SLPVectorizer/X86/control-dependence.ll
    M llvm/test/Transforms/SLPVectorizer/X86/crash_mandeltext.ll
    M llvm/test/Transforms/SLPVectorizer/X86/crash_smallpt.ll
    M llvm/test/Transforms/SLPVectorizer/X86/cse.ll
    M llvm/test/Transforms/SLPVectorizer/X86/ctlz.ll
    M llvm/test/Transforms/SLPVectorizer/X86/ctpop.ll
    M llvm/test/Transforms/SLPVectorizer/X86/cttz.ll
    M llvm/test/Transforms/SLPVectorizer/X86/diamond.ll
    M llvm/test/Transforms/SLPVectorizer/X86/diamond_broadcast.ll
    M llvm/test/Transforms/SLPVectorizer/X86/diamond_broadcast_extra_shuffle.ll
    M llvm/test/Transforms/SLPVectorizer/X86/different-vec-widths.ll
    M llvm/test/Transforms/SLPVectorizer/X86/dot-product.ll
    M llvm/test/Transforms/SLPVectorizer/X86/extract_in_tree_user.ll
    M llvm/test/Transforms/SLPVectorizer/X86/fabs.ll
    M llvm/test/Transforms/SLPVectorizer/X86/fcopysign.ll
    M llvm/test/Transforms/SLPVectorizer/X86/fma.ll
    M llvm/test/Transforms/SLPVectorizer/X86/fmaxnum.ll
    M llvm/test/Transforms/SLPVectorizer/X86/fminnum.ll
    M llvm/test/Transforms/SLPVectorizer/X86/fmuladd.ll
    M llvm/test/Transforms/SLPVectorizer/X86/fptosi-inseltpoison.ll
    M llvm/test/Transforms/SLPVectorizer/X86/fptosi.ll
    M llvm/test/Transforms/SLPVectorizer/X86/fptoui.ll
    M llvm/test/Transforms/SLPVectorizer/X86/fround.ll
    M llvm/test/Transforms/SLPVectorizer/X86/funclet.ll
    M llvm/test/Transforms/SLPVectorizer/X86/gep.ll
    M llvm/test/Transforms/SLPVectorizer/X86/horizontal-list.ll
    M llvm/test/Transforms/SLPVectorizer/X86/horizontal-minmax.ll
    M llvm/test/Transforms/SLPVectorizer/X86/horizontal.ll
    M llvm/test/Transforms/SLPVectorizer/X86/insert-after-bundle.ll
    M llvm/test/Transforms/SLPVectorizer/X86/insert-element-build-vector-inseltpoison.ll
    M llvm/test/Transforms/SLPVectorizer/X86/insert-element-build-vector.ll
    M llvm/test/Transforms/SLPVectorizer/X86/insert-shuffle.ll
    M llvm/test/Transforms/SLPVectorizer/X86/insertvalue.ll
    M llvm/test/Transforms/SLPVectorizer/X86/intrinsic_with_scalar_param.ll
    M llvm/test/Transforms/SLPVectorizer/X86/jumbled-load-shuffle-placement.ll
    M llvm/test/Transforms/SLPVectorizer/X86/jumbled-load.ll
    M llvm/test/Transforms/SLPVectorizer/X86/jumbled_store_crash.ll
    M llvm/test/Transforms/SLPVectorizer/X86/load-merge-inseltpoison.ll
    M llvm/test/Transforms/SLPVectorizer/X86/load-merge.ll
    M llvm/test/Transforms/SLPVectorizer/X86/lookahead.ll
    M llvm/test/Transforms/SLPVectorizer/X86/metadata.ll
    M llvm/test/Transforms/SLPVectorizer/X86/phi_overalignedtype.ll
    M llvm/test/Transforms/SLPVectorizer/X86/powof2div.ll
    M llvm/test/Transforms/SLPVectorizer/X86/powof2mul.ll
    M llvm/test/Transforms/SLPVectorizer/X86/pr35497.ll
    M llvm/test/Transforms/SLPVectorizer/X86/pr47629-inseltpoison.ll
    M llvm/test/Transforms/SLPVectorizer/X86/pr47629.ll
    M llvm/test/Transforms/SLPVectorizer/X86/remark_horcost.ll
    M llvm/test/Transforms/SLPVectorizer/X86/reorder_diamond_match.ll
    M llvm/test/Transforms/SLPVectorizer/X86/resched.ll
    M llvm/test/Transforms/SLPVectorizer/X86/return.ll
    M llvm/test/Transforms/SLPVectorizer/X86/schedule_budget.ll
    M llvm/test/Transforms/SLPVectorizer/X86/scheduling.ll
    M llvm/test/Transforms/SLPVectorizer/X86/shift-ashr.ll
    M llvm/test/Transforms/SLPVectorizer/X86/shift-lshr.ll
    M llvm/test/Transforms/SLPVectorizer/X86/shift-shl.ll
    M llvm/test/Transforms/SLPVectorizer/X86/shrink_after_reorder.ll
    M llvm/test/Transforms/SLPVectorizer/X86/simple-loop.ll
    M llvm/test/Transforms/SLPVectorizer/X86/simplebb.ll
    M llvm/test/Transforms/SLPVectorizer/X86/sitofp-inseltpoison.ll
    M llvm/test/Transforms/SLPVectorizer/X86/sitofp.ll
    M llvm/test/Transforms/SLPVectorizer/X86/split-load8_2-unord.ll
    M llvm/test/Transforms/SLPVectorizer/X86/sqrt.ll
    M llvm/test/Transforms/SLPVectorizer/X86/stacksave-dependence.ll
    M llvm/test/Transforms/SLPVectorizer/X86/store-jumbled.ll
    M llvm/test/Transforms/SLPVectorizer/X86/stores-non-ordered.ll
    M llvm/test/Transforms/SLPVectorizer/X86/stores_vectorize.ll
    M llvm/test/Transforms/SLPVectorizer/X86/tiny-tree.ll
    M llvm/test/Transforms/SLPVectorizer/X86/uitofp.ll
    M llvm/test/Transforms/SLPVectorizer/X86/vectorize-reorder-alt-shuffle.ll
    M llvm/test/Transforms/SLPVectorizer/X86/vectorize-reordered-list.ll
    M llvm/test/Transforms/SLPVectorizer/int_sideeffect.ll
    M llvm/test/Transforms/SLPVectorizer/slp-max-phi-size.ll

  Log Message:
  -----------
  Reapply "[SLP] Schedule only sub-graph of vectorizable instructions"" (try 3)

The original commit exposed several missing dependencies (e.g. latent bugs in SLP scheduling).  Most of these were fixed over the weekend and have had several days to bake.  The last was fixed this morning after being noticed in manual review of test changes yesterday.  See the review thread for links to each change.

Original commit message follows:

SLP currently schedules all instructions within a scheduling window which stretches from the first instruction potentially vectorized to the last. This window can include a very large number of unrelated instructions which are not being considered for vectorization. This change switches the code to only schedule the sub-graph consisting of the instructions being vectorized and their transitive users.

This has the effect of greatly reducing the amount of work performed in large basic blocks, and thus greatly improves compile time on degenerate examples. To understand the effects, I added some statistics (not planned for upstream contribution). Here's an illustration from my motivating example:

   Before this patch:

   704357 SLP                          - Number of calcDeps actions
   699021 SLP                          - Number of schedule calls
   5598 SLP                          - Number of ReSchedule actions
   59 SLP                          - Number of ReScheduleOnFail actions
   10084 SLP                          - Number of schedule resets
   8523 SLP                          - Number of vector instructions generated

   After this patch:

   102895 SLP                          - Number of calcDeps actions
   161916 SLP                          - Number of schedule calls
   5637 SLP                          - Number of ReSchedule actions
   55 SLP                          - Number of ReScheduleOnFail actions
   10083 SLP                          - Number of schedule resets
   8403 SLP                          - Number of vector instructions generated

I do want to highlight that there is a small difference in number of generated vector instructions. This example is hitting the bailout due to maximum window size, and the change in scheduling is slightly perturbing when and how we hit it. This can be seen in the RescheduleOnFail counter change. Given that, I think we can safely ignore.

The downside of this change can be seen in the large test diff. We group all vectorizable instructions together at the bottom of the scheduling region. This means that vector instructions can move quite far from their original point in code. While maybe undesirable, I don't see this as being a major problem as this pass is not intended to be a general scheduling pass.

For context, it's worth noting that the pre-scheduling that SLP does while building the vector tree is exactly the sub-graph scheduling implemented by this patch.

Differential Revision: https://reviews.llvm.org/D118538




More information about the All-commits mailing list