[all-commits] [llvm/llvm-project] 844d8e: [GlobalISel] Combine icmp eq/ne x, 0/1 -> x when x...

Jessica Paquette via All-commits all-commits at lists.llvm.org
Thu Sep 2 15:06:00 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 844d8e0337560bd73b5a78fd8ff162b1b262b46f
      https://github.com/llvm/llvm-project/commit/844d8e0337560bd73b5a78fd8ff162b1b262b46f
  Author: Jessica Paquette <jpaquette at apple.com>
  Date:   2021-09-02 (Thu, 02 Sep 2021)

  Changed paths:
    M llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
    M llvm/include/llvm/Target/GlobalISel/Combine.td
    M llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
    A llvm/test/CodeGen/AArch64/GlobalISel/combine-icmp-to-lhs-known-bits.mir

  Log Message:
  -----------
  [GlobalISel] Combine icmp eq/ne x, 0/1 -> x when x == 0 or 1

This adds the following combines:

```
x = ... 0 or 1
c = icmp eq x, 1

->

c = x
```

and

```
x = ... 0 or 1
c = icmp ne x, 0

->

c = x
```

When the target's true value for the relevant types is 1.

This showed up in the following situation:

https://godbolt.org/z/M5jKexWTW

SDAG currently supports the `ne` case, but not the `eq` case. This can probably
be further generalized, but I don't feel like thinking that hard right now.

This gives some minor code size improvements across the board on CTMark at
-Os for AArch64. (0.1% for 7zip and pairlocalalign in particular.)

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




More information about the All-commits mailing list