[all-commits] [llvm/llvm-project] 928305: [AArch64][GlobalISel] Fold G_ADD into the cset for...

Jessica Paquette via All-commits all-commits at lists.llvm.org
Wed Feb 10 13:28:36 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 9283058abbec3d2236e69556206b4e66bf52045b
      https://github.com/llvm/llvm-project/commit/9283058abbec3d2236e69556206b4e66bf52045b
  Author: Jessica Paquette <jpaquette at apple.com>
  Date:   2021-02-10 (Wed, 10 Feb 2021)

  Changed paths:
    M llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
    M llvm/test/CodeGen/AArch64/GlobalISel/select-cmp.mir

  Log Message:
  -----------
  [AArch64][GlobalISel] Fold G_ADD into the cset for G_ICMP

When we have a G_ADD which is fed by a G_ICMP on one side, we can fold it into
the cset for the G_ICMP.

e.g. Given

```
%cmp = G_ICMP ... %x, %y
%add = G_ADD %cmp, %z
```

We would normally emit a cmp, cset, and add.

However, `%add` is either `%z` or `%z + 1`. So, we can just use `%z` as the
source of the cset rather than wzr, saving an instruction.

This would probably be cleaner in AArch64PostLegalizerLowering, but we'd need
to change the way we represent G_ICMP to do that, I think. For now, it's
easiest to implement in selection.

This is a 0.1% code size improvement on CTMark/pairlocalalign at -Os.

Example: https://godbolt.org/z/7KdrP8

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




More information about the All-commits mailing list