The following patch fixes https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87718   The patch adds a special treatment for moves with a hard register in register cost and class calculation.   The patch was bootstrapped and tested on x86-64 and ppc64.   I found two testsuite regressions because of the patch.  The expected generated code for PR82361 test is too specific.  GCC with the patch generates the same quality code but with a different hard register on x86-64.  So I just changed the test for  PR82361.   Another test is for ppc64.  I think the expected generated code for this test is wrong.  I'll submit a changed test for a discussion later.   Although I spent much time on the solution and I think it is the right one, the patch is in very sensitive area of RA and may affect expected code generation for many targets.  I am ready to work on the new regressions as soon as they are found.   The patch was committed as rev. 260385.