[all-commits] [llvm/llvm-project] 60d9e6: [IRCE] Relax profitability check (#104659)

Jan Ječmen via All-commits all-commits at lists.llvm.org
Thu Dec 12 08:11:28 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 60d9e6fba884048e1047a208b61f0dfd8baabaaa
      https://github.com/llvm/llvm-project/commit/60d9e6fba884048e1047a208b61f0dfd8baabaaa
  Author: Jan Ječmen <JanJecmen at users.noreply.github.com>
  Date:   2024-12-12 (Thu, 12 Dec 2024)

  Changed paths:
    M llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
    M llvm/test/Transforms/IRCE/low-iterations.ll
    A llvm/test/Transforms/IRCE/profitability.ll

  Log Message:
  -----------
  [IRCE] Relax profitability check (#104659)

IRCE currently has two profitability checks:

1. min number of iterations (10 by default)
2. branch is highly biased (> 15/16)

However, it may still be profitable to eliminate range checks even if
the branch isn't as biased. Consider, for example, a loop with 100
iterations, where IRCE currently eliminates all 100 range checks. The
same range checks performed over a loop with 200 iterations aren't
eliminated because the branch is 50-50.

This patch proposes to relax the profitability checks of IRCE. Namely,
instead of the two checks currenly in place, consider IRCE profitable if
the branch probability scaled by the expected number of iterations
(i.e., the estimated number of eliminated checks) is over a threshold.
This covers the minimum number of iterations check (there are at least
as many iterations as eliminated range checks), and changes the bias
check from a percent of iterations to at least a constant threshold of
eliminated checks.

If the number of iterations can't be estimated, the check falls back to
the current 15/16 likelihood check.



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