[GlobalISel] Handle more types in narrowScalar for eq/ne G_ICMP
authorJessica Paquette <jpaquette@apple.com>
Wed, 30 Jun 2021 00:01:28 +0000 (17:01 -0700)
committerJessica Paquette <jpaquette@apple.com>
Tue, 13 Jul 2021 05:18:50 +0000 (22:18 -0700)
commit47d0780f454d3f7c42bdba13c0682bf2a0095bca
tree5c769c46478c06b80b47846818381d6d24d3f68c
parentb8424b42a58ee4cf8ca423de39993ed97f98f0bc
[GlobalISel] Handle more types in narrowScalar for eq/ne G_ICMP

Generalize the existing eq/ne case using `extractParts`. The original code only
handled narrowings for types of width 2n->n. This generalization allows for any
type that can be broken down by `extractParts`.

General overview is:

- Loop over each narrow-sized part and do exactly what the 2-register case did.
- Loop over the leftover-sized parts and do the same thing
- Widen the leftover-sized XOR results to the desired narrow size
- OR that all together and then do the comparison against 0 (just like the old
  code)

This shows up a lot when building clang for AArch64 using GlobalISel, so it's
worth fixing. For the sake of simplicity, this doesn't handle the non-eq/ne
case yet.

Also remove the code in this case that notifies the observer; we're just going
to delete MI anyway so talking to the observer shouldn't be necessary.

Differential Revision: https://reviews.llvm.org/D105161
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
llvm/test/CodeGen/AArch64/GlobalISel/legalize-cmp.mir