[all-commits] [llvm/llvm-project] 30e49a: [InstCombine] Optimise shift+and+boolean conversio...

chenglin.bi via All-commits all-commits at lists.llvm.org
Thu Jun 23 06:53:36 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 30e49a3794726fd9d0ae60d34880f15e64a9fb3f
      https://github.com/llvm/llvm-project/commit/30e49a3794726fd9d0ae60d34880f15e64a9fb3f
  Author: chenglin.bi <chenglin.bi at cixcomputing.com>
  Date:   2022-06-23 (Thu, 23 Jun 2022)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
    M llvm/test/Transforms/InstCombine/icmp-and-shift.ll

  Log Message:
  -----------
  [InstCombine] Optimise shift+and+boolean conversion pattern to simple comparison

if (`C1` is pow2) & (`(C2 & ~(C1-1)) + C1)` is pow2):
    ((C1 << X) & C2) == 0 -> X >= (Log2(C2+C1) - Log2(C1));
https://alive2.llvm.org/ce/z/EJAl1R
    ((C1 << X) & C2) != 0 -> X  < (Log2(C2+C1) - Log2(C1));
https://alive2.llvm.org/ce/z/3bVRVz

And remove dead code.

Fix: https://github.com/llvm/llvm-project/issues/56124

Reviewed By: spatel

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




More information about the All-commits mailing list