https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92905
--- Comment #5 from Vladimir Makarov <vmakarov at gcc dot gnu.org> --- (In reply to Jakub Jelinek from comment #3) > Note, it isn't about <g>, using r<i>m in the first alternative of the > reverted define_insn works well too, as well as swapping the alternatives > (that is in that case basically what the trunk has, except in the second > alternative the second input is r<i>m instead of m. If the second > alternative of second input is <i>m, > it works the same as current trunk (unnecessary spill), if it is rm, it > works well. > Now, no idea if this isn't a bug in LRA or if there are some rules that the > seemingly redundant constraints actually aren't redundant. The culprit is 'g' vs 'm'. When we have 'g' matching pseudo assigned to hard register, LRA ignores memory in 'g' when considering preferred_reload_class. Reload also treats such situation in analogous way. And actually LRA adapted the reload code. So I can try to solve this PR. But it will take some time. Mostly any patch in this sensitive area should be tested and benchmarked well.