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

Alexander Shaposhnikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 25 10:50:50 PDT 2022


alexander-shaposhnikov added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:1684
+  unsigned BitWidth = XType->getScalarSizeInBits();
+  if (Shift <= 2 || Shift > BitWidth || C.logBase2() != (BitWidth - Shift + 1))
+    return nullptr;
----------------
majnemer wrote:
> Why 2?
if Shift =2 and BitWidth = 32 then (BitWidth - Shift + 1) = 31 and 2^(BitWidth - Shift + 2) = (C << 1) doesn't fit into i32
https://alive2.llvm.org/ce/z/HhGAA3


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