[PATCH] D130433: [InstCombine] Add fold for redundant sign bits count comparison

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 27 05:42:18 PDT 2022


spatel added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:1688-1689
+  unsigned BitWidth = XType->getScalarSizeInBits();
+  if (Shift == 0 || Shift > BitWidth || PowerOf2.logBase2() < 2 ||
+      PowerOf2.logBase2() > BitWidth - 2)
+    return nullptr;
----------------
spatel wrote:
> I think this is still over-specified. It seems all we need is a non-zero shift and a power-of-2 compare constant:
> https://alive2.llvm.org/ce/z/adaQ_n
Sorry - I botched that code. We do have to guard against overflow when we increment the cmp constant:
https://alive2.llvm.org/ce/z/eEUfx3


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130433/new/

https://reviews.llvm.org/D130433



More information about the llvm-commits mailing list