http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60418
--- Comment #11 from H.J. Lu <hjl.tools at gmail dot com> --- sort_by_operand_rank in reassoc.cin has /* Lastly, make sure the versions that are the same go next to each other. We use SSA_NAME_VERSION because it's stable. */ if ((oeb->rank - oea->rank == 0) && TREE_CODE (oea->op) == SSA_NAME && TREE_CODE (oeb->op) == SSA_NAME) { if (SSA_NAME_VERSION (oeb->op) != SSA_NAME_VERSION (oea->op)) return SSA_NAME_VERSION (oeb->op) - SSA_NAME_VERSION (oea->op); else return oeb->id - oea->id; } It will treat powmult_80 = dx11_70 * dx11_70; powmult_241 = dy11_71 * dy11_71; _75 = powmult_80 + powmult_241; powmult_240 = dz11_72 * dz11_72; rsq11_77 = _75 + powmult_240; where powmult_240 is between powmult_80 and powmult_241, differently from powmult_80 = dx11_70 * dx11_70; powmult_213 = dy11_71 * dy11_71; _75 = powmult_80 + powmult_213; powmult_244 = dz11_72 * dz11_72; rsq11_77 = _75 + powmult_244; where powmult_244 > powmult_80 and powmult_213.