https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93119
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Created attachment 47663 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47663&action=edit Patch which fixes the problem So we need to accept P modes and not PTR modes for the aarch64_valid_symref. And then we need to also change the mode of the result to be always Pmode (DImode). And then we need to take the lower part of the result. Oh also instead of checking if we are targetting ILP32, we need to check the type of imm and such.