[AArch64][GlobalISel] Fold 64-bit cmps with 64-bit adds
authorJessica Paquette <jpaquette@apple.com>
Mon, 4 Oct 2021 18:53:37 +0000 (11:53 -0700)
committerJessica Paquette <jpaquette@apple.com>
Thu, 21 Oct 2021 20:51:44 +0000 (13:51 -0700)
commit5dc339d9825f1dbe788cfb69c88210a59bbf8e3a
tree0a9180fdbfcb563cd3b2bb668483ca011b3b920d
parent2ba572a82a35051cdee91f6bb00d3db322ae13a3
[AArch64][GlobalISel] Fold 64-bit cmps with 64-bit adds

G_ICMP is selected to an arithmetic overflow op (ADDS/SUBS/etc) with a dead
destination + a CSINC instruction.

We have a fold which allows us to combine 32-bit adds with G_ICMP.

The problem with G_ICMP is that we model it as always having a 32-bit
destination even though it can be a 64-bit operation. So, we were missing some
opportunities for 64-bit folds.

This patch teaches the fold to recognize 64-bit G_ICMPs + refactors some of
the code surrounding CSINC accordingly.

(Later down the line, I think we should probably change the way we handle G_ICMP
in general.)

Differential Revision: https://reviews.llvm.org/D111088
llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
llvm/test/CodeGen/AArch64/GlobalISel/select-cmp.mir