[all-commits] [llvm/llvm-project] f3731d: [LoopUnroll] Update branch weight for remainder loop

Hongtao Yu via All-commits all-commits at lists.llvm.org
Wed Jul 15 12:34:03 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: f3731d34faa7432462c877714af235e9787c9b30
      https://github.com/llvm/llvm-project/commit/f3731d34faa7432462c877714af235e9787c9b30
  Author: Hongtao Yu <hoy at fb.com>
  Date:   2020-07-15 (Wed, 15 Jul 2020)

  Changed paths:
    M llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
    A llvm/test/Transforms/LoopUnroll/runtime-loop-branchweight.ll

  Log Message:
  -----------
  [LoopUnroll] Update branch weight for remainder loop

Unrolling a loop with compile-time unknown trip count results in a remainder loop. The remainder loop executes the remaining iterations of the original loop when the original trip count is not a multiple of the unroll factor. For better profile counts maintenance throughout the optimization pipeline, I'm assigning an artificial weight to the latch branch of the remainder loop.

A remainder loop runs up to as many times as the unroll factor subtracted by 1. Therefore I'm assigning the maximum possible trip count as the back edge weight. This should be more accurate than the default non-profile weight, which assumes the back edge runs much more frequently than the exit edge.

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




More information about the All-commits mailing list