[PATCH] D14590: [SimplifyLibCalls] Constant folding for fls, flsl, flsll

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 15 13:06:33 PST 2016


efriedma added inline comments.


================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:1551
+  // Constant fold.
+  if (ConstantInt *CI = dyn_cast<ConstantInt>(Op)) {
+    if (CI->isZero()) // fls(0) -> 0.
----------------
There isn't much point to keeping this around; the general-case code will constant-fold anyway.


================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:1560
+
+  // ffs(x) -> x != 0 ? (i32)(sizeInBits(x) - llvm.ctlz(x)) : 0
+  Type *ArgType = Op->getType();
----------------
"sizeInBits(x) - llvm.ctlz(x, false)" is equivalent, I think?


https://reviews.llvm.org/D14590





More information about the llvm-commits mailing list