This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][GlobalISel] Select Bcc when it's better than TB(N)Z
ClosedPublic

Authored by paquette on Nov 30 2020, 5:29 PM.

Details

Summary

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.

Diff Detail

Event Timeline

paquette created this revision.Nov 30 2020, 5:29 PM
paquette requested review of this revision.Nov 30 2020, 5:29 PM
aemerson added inline comments.Dec 1 2020, 12:25 AM
llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
1427–1428

We can cache the getType().

1513–1520

Seems we lost the comment for this case.

1523

The type must be <= 64 for scalars right?

paquette updated this revision to Diff 308714.Dec 1 2020, 11:03 AM

Tidy up logic a little, improve comments, and address review comments.

aemerson accepted this revision.Dec 1 2020, 2:44 PM
aemerson added inline comments.
llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
1432
This revision is now accepted and ready to land.Dec 1 2020, 2:44 PM