[all-commits] [llvm/llvm-project] d25b12: [GlobalISel] Add combine for (x & mask) -> x when ...

Jessica Paquette via All-commits all-commits at lists.llvm.org
Wed Aug 19 10:21:45 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: d25b12bdc307264e353f1a3c4ccd65c0b45b2f86
      https://github.com/llvm/llvm-project/commit/d25b12bdc307264e353f1a3c4ccd65c0b45b2f86
  Author: Jessica Paquette <jpaquette at apple.com>
  Date:   2020-08-19 (Wed, 19 Aug 2020)

  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
    M llvm/lib/Target/AArch64/AArch64Combine.td
    A llvm/test/CodeGen/AArch64/GlobalISel/postlegalizer-combiner-and-trivial-mask.mir

  Log Message:
  -----------
  [GlobalISel] Add combine for (x & mask) -> x when (x & mask) == x

If we have a mask, and a value x, where (x & mask) == x, we can drop the AND
and just use x.

This is about a 0.4% geomean code size improvement on CTMark at -O3 for AArch64.

In AArch64, this is most useful post-legalization. Patterns like this often
show up when legalizing s1s, which must be extended to larger types.

e.g.

```
%cmp:_(s32) = G_ICMP ...
%and:_(s32) = G_AND %cmp, 1
```

Since G_ICMP only produces a single bit, there's no reason to mask it with the
G_AND.

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




More information about the All-commits mailing list