[all-commits] [llvm/llvm-project] 087bb0: Allow scalable vectors in computeKnownBits
Philip Reames via All-commits
all-commits at lists.llvm.org
Sun Oct 30 09:00:53 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 087bb0f1fe1c5a3f17eeea3537218b2be5d18f34
https://github.com/llvm/llvm-project/commit/087bb0f1fe1c5a3f17eeea3537218b2be5d18f34
Author: Philip Reames <preames at rivosinc.com>
Date: 2022-10-30 (Sun, 30 Oct 2022)
Changed paths:
M llvm/lib/Analysis/ValueTracking.cpp
M llvm/test/Transforms/InstCombine/add.ll
M llvm/test/Transforms/InstCombine/intrinsics.ll
Log Message:
-----------
Allow scalable vectors in computeKnownBits
This extends the computeKnownBits analysis to support scalable vectors. The critical detail is in deciding how to represent the demanded elements of a vector whose length is unknown at compile time.
For this patch, I adopt the convention that we track one bit which corresponds to all lanes. That is, that bit is implicitly broadcast to all lanes of the scalable vector resulting in all lanes being demanded. This is the same convention we use in getSplatValue in SelectionDAG.
Note that this convention doesn't actually impact much. Most of the code is agnostic to the interpretation of the demanded elements, and the few cases which actually care need case by case handling anyways. In this patch, I just bail out of those cases.
A prior patch (D128159) proposed using a different convention in SDAG. I don't see any strong reason to prefer one scheme over the other, so I propose we go with this one as it's conceptually the simplest. Getting known and demanded bit optimizations unblocked at all is a significant win.
I've locally implemented this scheme in reasonable large parts of ValueTracking.cpp and SelectionDAG equivalents, and have not hit any blockers. If this is approved, I plan to post a series of patches plumbing this through all the relevant parts.
In the discussion on that patch, a preference was expressed for introducing some form of abstraction around the demanded elements. I'll note that I've played with several variations on that idea locally, and have yet to find anything which results in more readable code. If anyone has concrete ideas in this area, I'm happy to explore in follow up patches. I'd strongly prefer to be making API changes in NFC manner with tests in place.
Differential Revision: https://reviews.llvm.org/D136470
More information about the All-commits
mailing list