[all-commits] [llvm/llvm-project] 3be8e2: [InstCombine] Prefer to keep power-of-2 constants ...

Alex Bradbury via All-commits all-commits at lists.llvm.org
Fri May 10 05:50:24 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3be8e2c95d3dca5b2fdea889649a69dce8605e65
      https://github.com/llvm/llvm-project/commit/3be8e2c95d3dca5b2fdea889649a69dce8605e65
  Author: Alex Bradbury <asb at igalia.com>
  Date:   2024-05-10 (Fri, 10 May 2024)

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

  Log Message:
  -----------
  [InstCombine] Prefer to keep power-of-2 constants when combining ashr exact and slt/ult of a constant (#86111)

We have flexibility in what constant to use when combining an `ashr
exact` with a slt or ult of a constant, and it's not possible to revisit
this decision later in the compilation pipeline after the `ashr exact`
is removed. Keeping a constant close to power-of-2 (pow2val + 1) should
be no worse than neutral, and in some cases may allow better codegen
later on for targets that can more cheaply generate power of 2 (which
may be selectable if converting back to setle/setge) or near power of 2
constants.

Alive2 proofs:
<https://alive2.llvm.org/ce/z/2BmPnq> and
<https://alive2.llvm.org/ce/z/DtuhnR>



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