------- Comment #2 from dberlin at gcc dot gnu dot org 2006-08-11 14:33 ------- Subject: Re: [4.2 Regression] Performace problem with indexed load/stores on powerpc
Here is the reassoc patch that puts them in the right order at the tree level. Index: tree-ssa-reassoc.c =================================================================== --- tree-ssa-reassoc.c (revision 115962) +++ tree-ssa-reassoc.c (working copy) @@ -356,6 +356,13 @@ sort_by_operand_rank (const void *pa, co && TREE_CODE (oeb->op) == SSA_NAME) return SSA_NAME_VERSION (oeb->op) - SSA_NAME_VERSION (oea->op); + /* For pointers, most things want the *base* pointer to go first to + try indexed loads. The base pointer is the one with the *lesser* + rank. For everything else, put them in order from greatest rank + to least. */ + if (POINTER_TYPE_P (TREE_TYPE (oea->op))) + return oea->rank - oeb->rank; + return oeb->rank - oea->rank; } @@ -1309,7 +1316,9 @@ reassociate_bb (basic_block bb) if (TREE_CODE (stmt) == MODIFY_EXPR) { tree lhs = TREE_OPERAND (stmt, 0); + tree lhst = TREE_TYPE (lhs); tree rhs = TREE_OPERAND (stmt, 1); + tree rhst = TREE_TYPE (rhs); /* If this was part of an already processed tree, we don't need to touch it again. */ @@ -1318,10 +1327,10 @@ reassociate_bb (basic_block bb) /* If unsafe math optimizations we can do reassociation for non-integral types. */ - if ((!INTEGRAL_TYPE_P (TREE_TYPE (lhs)) - || !INTEGRAL_TYPE_P (TREE_TYPE (rhs))) - && (!SCALAR_FLOAT_TYPE_P (TREE_TYPE (rhs)) - || !SCALAR_FLOAT_TYPE_P (TREE_TYPE(lhs)) + if (((!INTEGRAL_TYPE_P (lhst) & !POINTER_TYPE_P (lhst)) + || (!INTEGRAL_TYPE_P (rhst) && !POINTER_TYPE_P (rhst))) + && (!SCALAR_FLOAT_TYPE_P (rhst) + || !SCALAR_FLOAT_TYPE_P (lhst) || !flag_unsafe_math_optimizations)) continue; -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28690