[PATCH] D45173: [InstCombine] Recognize idioms for ctpop and ctlz

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 2 21:36:52 PDT 2018


craig.topper added inline comments.


================
Comment at: lib/Transforms/AggressiveInstCombine/BitCountCombine.cpp:61
+      const APInt *P = &M;
+      auto Mask = m_APInt(P);
+      auto Shift = m_SpecificInt(S);
----------------
m_APInt doesn't match a specific APInt. It just matches any ConstantInt or splat and returns a pointer to the APInt it found. The pointer passed in would normally be unitialized in the caller.


================
Comment at: lib/Transforms/AggressiveInstCombine/BitCountCombine.cpp:98
+    APInt T(BW, 0);
+    while (M != 0) {
+      T |= M;
----------------
Could this make use of APInt::getSplat?


================
Comment at: lib/Transforms/AggressiveInstCombine/BitCountCombine.cpp:106
+  Value *V = &In;
+  bool SA = true;
+  unsigned N = BW;
----------------
Spell this out? 'SA' isn't meaningful without looking at the lambda being called.


Repository:
  rL LLVM

https://reviews.llvm.org/D45173





More information about the llvm-commits mailing list