[all-commits] [llvm/llvm-project] 9effe3: [AArch64][GlobalISel] Fold G_XOR into TB(N)Z bit c...

Jessica Paquette via All-commits all-commits at lists.llvm.org
Mon Feb 3 15:25:21 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 9effe38b225f3dfd72d6f1800f2ea47175b5bf95
      https://github.com/llvm/llvm-project/commit/9effe38b225f3dfd72d6f1800f2ea47175b5bf95
  Author: Jessica Paquette <jpaquette at apple.com>
  Date:   2020-02-03 (Mon, 03 Feb 2020)

  Changed paths:
    M llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp
    A llvm/test/CodeGen/AArch64/GlobalISel/opt-fold-xor-tbz-tbnz.mir

  Log Message:
  -----------
  [AArch64][GlobalISel] Fold G_XOR into TB(N)Z bit calculation

This ports the existing case for G_XOR from `getTestBitOperand` in
AArch64ISelLowering into GlobalISel.

The idea is to flip between TBZ and TBNZ while walking through G_XORs.

Let's say we have

```
tbz (xor x, c), b
```

Let's say the `b`-th bit in `c` is 1. Then

- If the `b`-th bit in `x` is 1, the `b`-th bit in `(xor x, c)` is 0.
- If the `b`-th bit in `x` is 0, then the `b`-th bit in `(xor x, c)` is 1.

So, then

```
tbz (xor x, c), b == tbnz x, b
```

Let's say the `b`-th bit in `c` is 0. Then

- If the `b`-th bit in `x` is 1, the `b`-th bit in `(xor x, c)` is 1.
- If the `b`-th bit in `x` is 0, then the `b`-th bit in `(xor x, c)` is 0.

So, then

```
tbz (xor x, c), b == tbz x, b
```

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




More information about the All-commits mailing list