https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109592
--- Comment #7 from Jeffrey A. Law <law at gcc dot gnu.org> --- Attached is what I cobbled together. It doesn't use magic numbers. But it doesn't yet handle zero extensions in the simplify-rtx code. But I think it shows the overall direction fairly well.