This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][GlobalISel] Fold G_XOR into TB(N)Z bit calculation
ClosedPublic

Authored by paquette on Feb 3 2020, 2:56 PM.

Details

Summary

This ports the existing case for G_XOR from getTestBitOperand in AArch64ISelLowering into GlobalISel.

The idea is to flip between TBZ and TBNZ while walking through G_XORs.

Let's say we have

tbz (xor x, c), b

Let's say the b-th bit in c is 1. Then

  • If the b-th bit in x is 1, the b-th bit in (xor x, c) is 0.
  • If the b-th bit in x is 0, then the b-th bit in (xor x, c) is 1.

So, then

tbz (xor x, c), b == tbnz x, b

Let's say the b-th bit in c is 0. Then

  • If the b-th bit in x is 1, the b-th bit in (xor x, c) is 1.
  • If the b-th bit in x is 0, then the b-th bit in (xor x, c) is 0.

So, then

tbz (xor x, c), b == tbz x, b

Diff Detail

Event Timeline

paquette created this revision.Feb 3 2020, 2:56 PM
aemerson accepted this revision.Feb 3 2020, 3:11 PM

Can we have one extra test checking for a chain of G_XORs?

This revision is now accepted and ready to land.Feb 3 2020, 3:11 PM
paquette updated this revision to Diff 242221.Feb 3 2020, 3:21 PM

Add a xor chain test.

This revision was automatically updated to reflect the committed changes.