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

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 10 10:58:28 PST 2021


reames created this revision.
reames added reviewers: spatel, nikic, aqjune.
Herald added subscribers: dantrushin, javed.absar, hiraditya, mcrosier.
Herald added a reviewer: bollu.
reames requested review of this revision.
Herald added a project: LLVM.

The motivation for this is that I'm looking at an example that uses shifts as induction variables.  There's lots of other omissions, but one of the first I noticed is that we can't compute tight known bits.  (This indirectly causes SCEV's range analysis to produce very poor results as well.)

One specific question to reviewers.  This patch essentially treats all shifts as if they were not exact/nsw/nuw.  This is a valid interpretation, but I'm concerned it might differ from that taken elsewhere in the optimizer in a problematic way.  What is the best practice for this in known bits computation?

Compile time wise, this should be reasonable.  We locally match the recurrence using simple IR pattern matching, and only recurse on the operand once we found a recurrence.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96440

Files:
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/test/Analysis/ValueTracking/shift-recurrence-knownbits.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96440.322749.patch
Type: text/x-patch
Size: 7596 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210210/64e7ad38/attachment.bin>


More information about the llvm-commits mailing list