[PATCH] D88316: [InstCombine] recognizeBSwapOrBitReverseIdiom - recognise zext(bswap(trunc(x))) patterns (PR39793)

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 29 11:30:32 PDT 2020


RKSimon marked an inline comment as not done.
RKSimon added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/Local.cpp:3027-3029
+  if (isPowerOf2_32(BitProvenance.size())) {
+    // Keep halving the demanded width while the upper half is zero.
+    while (BitProvenance.size() > 2) {
----------------
lebedev.ri wrote:
> RKSimon wrote:
> > lebedev.ri wrote:
> > > Why is this restricted to powers of two?
> > Good catch - my solution was too focused on the original test cases - I'm looking at refactoring this now.
> I think this might suggest that there's second half of the puzzle missing,
> i.e. should this also know how to widen/pad the inputs so that it is applicable for `bswap`?
yes - shifted bswaps would be possible as a future development - a lot of the existing bitTransformIsCorrectForBSwap code would need to be refactored for that though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88316



More information about the llvm-commits mailing list