[AArch64][GlobalISel] Select Bcc when it's better than TB(N)Z
authorJessica Paquette <jpaquette@apple.com>
Tue, 1 Dec 2020 01:21:21 +0000 (17:21 -0800)
committerJessica Paquette <jpaquette@apple.com>
Tue, 1 Dec 2020 23:45:14 +0000 (15:45 -0800)
commit6c3fa97d8a628541c82d8981aabefcb2dcb29f17
treed6a8647ffe8dc41a49d5d93e847400f24ce6cf67
parent04424c69bc7b98e1bbd0480ed5cdc251c6c94521
[AArch64][GlobalISel] Select Bcc when it's better than TB(N)Z

Instead of falling back to selecting TB(N)Z when we fail to select an
optimized compare against 0, select Bcc instead.

Also simplify selectCompareBranch a little while we're here, because the logic
was kind of hard to follow.

At -O0, this is a 0.1% geomean code size improvement for CTMark.

A simple example of where this can kick in is here:
https://godbolt.org/z/4rra6P

In the example above, GlobalISel currently produces a subs, cset, and tbnz.
SelectionDAG, on the other hand, just emits a compare and b.le.

Differential Revision: https://reviews.llvm.org/D92358
llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
llvm/test/CodeGen/AArch64/GlobalISel/opt-and-tbnz-tbz.mir
llvm/test/CodeGen/AArch64/GlobalISel/tbnz-slt.mir