[all-commits] [llvm/llvm-project] 9551fc: Fold ashr-exact into a icmp-ugt.

Nadav Rotem via All-commits all-commits at lists.llvm.org
Fri Jan 14 12:59:14 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 9551fc57b7e98b27844ef840b13773844c738f92
      https://github.com/llvm/llvm-project/commit/9551fc57b7e98b27844ef840b13773844c738f92
  Author: Nadav Rotem <nadav256 at gmail.com>
  Date:   2022-01-14 (Fri, 14 Jan 2022)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
    M llvm/test/Transforms/InstCombine/icmp-shr-lt-gt.ll
    M llvm/test/Transforms/InstCombine/icmp-shr.ll

  Log Message:
  -----------
  Fold ashr-exact into a icmp-ugt.

This commit optimizes the code sequence:
  icmp-XXX (ashr-exact (X, C_1), C_2).

Instcombine already implements this optimization for sgt, and this
patch adds support to additional predicates. The transformation is legal
for all predicates if the 'exact' flag is set, and to SGE, UGE, SLT, ULT
when the exact flag is not present.

This pattern is found in the std::vector bounds checks code of the at()
method.

Alive2 proof:
https://alive2.llvm.org/ce/z/JT_WL8

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




More information about the All-commits mailing list