[all-commits] [llvm/llvm-project] 60820e: [InstCombine] try to canonicalize logical shift af...

Sanjay Patel via All-commits all-commits at lists.llvm.org
Tue Mar 22 06:11:09 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 60820e53ec9d3be028ce315f9b630b55c670b32e
      https://github.com/llvm/llvm-project/commit/60820e53ec9d3be028ce315f9b630b55c670b32e
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2022-03-22 (Tue, 22 Mar 2022)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
    M llvm/test/Transforms/InstCombine/bswap-fold.ll

  Log Message:
  -----------
  [InstCombine] try to canonicalize logical shift after bswap

When shifting by a byte-multiple:
bswap (shl X, C) --> lshr (bswap X), C
bswap (lshr X, C) --> shl (bswap X), C

This is an IR implementation of a transform suggested in D120648.
The "swaps cancel" test models the motivating optimization from
that proposal.

Alive2 checks (as noted in the other review, we could use
knownbits to handle shift-by-variable-amount, but that can be an
enhancement patch):
https://alive2.llvm.org/ce/z/pXUaRf
https://alive2.llvm.org/ce/z/ZnaMLf

Differential Revision: https://reviews.llvm.org/D122010




More information about the All-commits mailing list