https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120627
--- Comment #1 from Jeffrey A. Law <law at gcc dot gnu.org> --- Interesting little bug. If I'm reading the dump file correctly what appears to be happening is ext-dce (correctly) eliminate a zero extension in an assignment to (reg X). Later combine comes along and collapses way a zero extension to (reg Y) because the source is a promoted subreg with zero extension (but not of reg X). Either step in isolation is fine. It's the combination of the two that is the problem. (reg X) and (reg Y) are related by a copy and that's a key point here. When we eliminate the extension into (reg X), we have code which will scurry about and find any promoted subregs involving (reg X) and remove their promoted status. But in this case we need to remove the promoted status of (reg Y)! My worry is we have to build a transitive closure of impacted objects.