[all-commits] [llvm/llvm-project] c9325f: [DFAJumpThreading] Add an early exit heuristic for...

Usman Nadeem via All-commits all-commits at lists.llvm.org
Sat Mar 16 11:25:03 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c9325f8a2e7ec9bb9e0b28320aab4034bcb94a0d
      https://github.com/llvm/llvm-project/commit/c9325f8a2e7ec9bb9e0b28320aab4034bcb94a0d
  Author: Usman Nadeem <mnadeem at quicinc.com>
  Date:   2024-03-16 (Sat, 16 Mar 2024)

  Changed paths:
    M llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
    M llvm/test/Transforms/DFAJumpThreading/dfa-unfold-select.ll
    A llvm/test/Transforms/DFAJumpThreading/unpredictable-heuristic.ll

  Log Message:
  -----------
  [DFAJumpThreading] Add an early exit heuristic for unpredictable values (#85015)

Right now the algorithm does not exit on unpredictable values. It
waits until all the paths have been enumerated to see if any of
those paths have that value. Waiting this late leads to a lot of
wasteful computation and higher compile time.

In this patch I have added a heuristic that checks if the value
comes from the same inner loops as the switch, if so, then it is
likely that the value will also be seen on a threadable path and
the code in `getStateDefMap()` return an empty map.

I tested this on the llvm test suite and the only change in the
number of threaded switches was in 7zip (before 23, after 18).
In all of those cases the current algorithm was partially threading
the loop because it was hitting a limit on the number of paths to
be explored. On increasing this limit even the current algorithm
finds paths where the unpredictable value is seen.

Compile time(with pass enabled by default and this patch):

https://llvm-compile-time-tracker.com/compare.php?from=8c5e9cf737138aba22a4a8f64ef2c5efc80dd7f9&to=42c75d888058b35c6d15901b34e36251d8f766b9&stat=instructions:u



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list