When lowering G_LOAD in AArch64, a G_ANYEXT could have been inserted,
even if we were loading from a bigger stored and requesting a smaller
size.
The solution is changing the fixed usage of G_ANYEXT to a conditional
usage of TRUNC or G_ANYEXT depending on the size of the source and the
destination. This seems to avoid the crash in the legalizer.
A test case is included.
Could you generate the checks using the update_mir_test thing?
Like @aemerson pointed out the checks look wrong and I am wondering if you found another bug, or just forgot to update the test.