[all-commits] [llvm/llvm-project] 0dc646: [InstCombine] Add bswap(logic_op(bswap(x), y)) reg...

Austin Chang via All-commits all-commits at lists.llvm.org
Sun May 7 06:28:51 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0dc6468edbcf5490ef606f7583f5a35e800d285d
      https://github.com/llvm/llvm-project/commit/0dc6468edbcf5490ef606f7583f5a35e800d285d
  Author: Austin Chang <austin880625 at gmail.com>
  Date:   2023-05-07 (Sun, 07 May 2023)

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

  Log Message:
  -----------
  [InstCombine] Add bswap(logic_op(bswap(x), y)) regression test case; NFC

Fold the following case on IR InstCombine pass. This patch includes the new test cases for this optimization

bswap(logic_op(x, bswap(y))) -> logic_op(bswap(x), y)
bswap(logic_op(bswap(x), y)) -> logic_op(x, bswap(y))
bswap(logic_op(bswap(x), bswap(y))) -> logic_op(x, y) with multi-use

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


  Commit: fe733f54da6faca95070b36b1640dbca3e43d396
      https://github.com/llvm/llvm-project/commit/fe733f54da6faca95070b36b1640dbca3e43d396
  Author: Austin Chang <austin880625 at gmail.com>
  Date:   2023-05-07 (Sun, 07 May 2023)

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

  Log Message:
  -----------
  [InstCombine] Improve bswap + logic_op optimization

The patch implements a helper function that matches and fold the following cases in the InstCombine pass:

    bswap(logic_op(x, bswap(y))) -> logic_op(bswap(x), y)
    bswap(logic_op(bswap(x), y)) -> logic_op(x, bswap(y))
    bswap(logic_op(bswap(x), bswap(y))) -> logic_op(x, y) in multiuse case, which still reduces the number of instructions.

The helper function accepts bswap and bitreverse intrinsics. This patch folds the bswap cases and remain the bitreverse optimization for the future

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


Compare: https://github.com/llvm/llvm-project/compare/6321e4ddf7da...fe733f54da6f


More information about the All-commits mailing list