[PATCH] D142849: [ValueTracking] Add helper for handling `computeKnownBits` for and/xor/or; NFC
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 18 11:59:57 PST 2023
nikic added inline comments.
================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:1071
+
+ // We don't want to put this before the Known.One.isZero check.
+ switch (I->getOpcode()) {
----------------
I don't understand this comment.
================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:1087
+
+ // and(x, -x)/xor(x, x-1) are common idioms that will clearing all but
+ // lowest set bit. If we have a single known bit in x, we can clear all bits
----------------
clearing -> clear?
================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:1100
+ m_c_Add(m_Deferred(X), m_AllOnes()))))) {
+ if (IsAnd) {
+ // -(-x) == x so using whichever (LHS/RHS) gets us a better result.
----------------
It doesn't look like the and/xor cases here really share any code -- makes more sense to handle them in separate ifs ... or better, move them into the respective switch cases above?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D142849/new/
https://reviews.llvm.org/D142849
More information about the llvm-commits
mailing list