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

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 7 11:55:22 PDT 2021


spatel added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp:959
+                                           A->getType()->getScalarSizeInBits());
+    return replaceInstUsesWith(
+        Trunc,
----------------
We usually prefer to do something like:
  Value *NarrowCtlz = Builder.CreateIntrinsic(...);
  return BinaryOperator::CreateAdd(NarrowCtlz, WidthDiff);

The instcombine caller function then handles the replace uses and transfers the name of the existing value to the new value, so you don't have to do that explicitly. You should see a cosmetic (but not functional) difference if you regenerate the CHECK lines in the test files with that change.


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