Given
tb(n)z (and x, m), b
Where the b-th bit of m is 1,
tb(n)z (and x, m), b == tb(n)z x, b
So, we can walk past a G_AND in this case.
Also add test/CodeGen/AArch64/GlobalISel/opt-fold-and-tbz-tbnz.mir to test this.
Paths 
  |  Differential  D73790  
[AArch64][GlobalISel] Walk through G_AND in TB(N)Z bit calculation ClosedPublic Authored by paquette on Jan 31 2020, 9:17 AM. 
Details Summary Given tb(n)z (and x, m), b Where the b-th bit of m is 1, tb(n)z (and x, m), b == tb(n)z x, b So, we can walk past a G_AND in this case. Also add test/CodeGen/AArch64/GlobalISel/opt-fold-and-tbz-tbnz.mir to test this. 
Diff Detail 
 Event TimelineHerald added subscribers: Petar.Avramovic, hiraditya, kristof.beyls, rovka.  ·  View Herald Transcript 
 paquette marked an inline comment as done. Comment Actions
 (The case where the constant is on the other side does come up a couple times in the MultiSource tests at -O3.) This revision is now accepted and ready to land.Feb 3 2020, 11:15 AM Closed by commit rG2bd46444d734: [AArch64][GlobalISel] Walk through G_AND in TB(N)Z bit calculation (authored by paquette).  ·  Explain WhyFeb 3 2020, 11:57 AM This revision was automatically updated to reflect the committed changes. 
Revision Contents 
 
Diff 242143 llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp
 llvm/test/CodeGen/AArch64/GlobalISel/opt-fold-and-tbz-tbnz.mir
 
  | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
We need to be explicit here about which opcode's we're looking for.