[PATCH] D103788: [InstCombine] Eliminate casts to optimize ctlz operation

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 13 04:59:46 PDT 2021


spatel added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp:957
+    unsigned AWidth = A->getType()->getScalarSizeInBits();
+    APInt ZextWidth(32, SrcWidth);
+    if (AWidth == DestWidth && AWidth > ZextWidth.logBase2()) {
----------------
datta.nagraj wrote:
> I am not sure if the 32 should be hardcoded here, or there is some other way for creating the APInt out of SrcWidth. 
> Please guide here sir. @spatel 
You don't need to create an APInt; see "Log2_32()" in MathExtras.h.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103788



More information about the llvm-commits mailing list