[PATCH] D96440: [knownbits] Preserve known bits for small shift recurrences

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 10 14:51:47 PST 2021


nikic added inline comments.


================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:1031
+  if (MatchShiftRecurrence(O, StartV, StepV)) {
+    computeKnownBits(StartV, DemandedElts, Known2, Depth + 1, Q);
+    switch(Opcode) {
----------------
The context instruction here needs to be adjusted to the terminator of the block for the incoming value StartV. Context can't be preserved when looking through phis.


================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:1466
+        // recurrence itself to refine the result.
+        RefineRecurrence(LU, DemandedElts, Known, Known2, Depth, Q);
+
----------------
The surrounding code here is already handling other types of recurrences of the same form -- combining it with RefineRecurrence is rather odd, because it does it's own recurrence matching that is partially redundant with the code here. I think these should be integrated, or at least factored differently. The scaffolding here should work for the shift case as well (restricted to LL == I, as for Sub below), just with different KnownBits logic being applied.


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

https://reviews.llvm.org/D96440



More information about the llvm-commits mailing list