[all-commits] [llvm/llvm-project] 3d795b: [InstCombine] Handle a bitreverse idiom which ends...

Yingwei Zheng via All-commits all-commits at lists.llvm.org
Wed Jan 10 23:15:24 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3d795bdd4d9067e96b2ff9e6278a5b8847eebe2b
      https://github.com/llvm/llvm-project/commit/3d795bdd4d9067e96b2ff9e6278a5b8847eebe2b
  Author: Yingwei Zheng <dtcxzyw2333 at gmail.com>
  Date:   2024-01-11 (Thu, 11 Jan 2024)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
    M llvm/lib/Transforms/Utils/Local.cpp
    M llvm/test/Transforms/InstCombine/bitreverse.ll

  Log Message:
  -----------
  [InstCombine] Handle a bitreverse idiom which ends with a bswap (#77677)

This patch handles the following `bitreverse` idiom, which is found in
https://github.com/abseil/abseil-cpp/blob/8bd6445acc4bd0d123da2a44448b7218dfc70939/absl/crc/internal/crc.cc#L75-L80:

```
uint32_t ReverseBits(uint32_t bits) {
  bits = (bits & 0xaaaaaaaau) >> 1 | (bits & 0x55555555u) << 1;
  bits = (bits & 0xccccccccu) >> 2 | (bits & 0x33333333u) << 2;
  bits = (bits & 0xf0f0f0f0u) >> 4 | (bits & 0x0f0f0f0fu) << 4;
  return absl::gbswap_32(bits);
}
```

Alive2: https://alive2.llvm.org/ce/z/ZYXNmj




More information about the All-commits mailing list