Should gcc-4.0 apply mathematical associative rules for addition or multiplication

Fariborz Jahanian fjahanian@apple.com
Tue Oct 5 17:39:00 GMT 2004


On Oct 5, 2004, at 8:39 AM, Gabriel Dos Reis wrote:

>
> Please factor this into a separate (inline) function.  You're missing
> division for reals (RDIV_EXPR.
>

Please note that, associative_tree_code(....) already excludes 
RDIV_EXPR.

  if ((associative_tree_code (rhs_code) || rhs_code == MINUS_EXPR)
       && TREE_CODE (TREE_OPERAND (rhs, 0)) == SSA_NAME
       && is_gimple_min_invariant (TREE_OPERAND (rhs, 1)))
     {
       tree rhs_def_stmt = SSA_NAME_DEF_STMT (TREE_OPERAND (rhs, 0));

       /* See if the RHS_DEF_STMT has the same form as our statement.  */
       if (TREE_CODE (rhs_def_stmt) == MODIFY_EXPR)
         {
           tree rhs_def_rhs = TREE_OPERAND (rhs_def_stmt, 1);
           enum tree_code rhs_def_code = TREE_CODE (rhs_def_rhs);

           if ((rhs_code == rhs_def_code
                && !(!flag_unsafe_math_optimizations
                     && (rhs_code == MULT_EXPR || rhs_code == PLUS_EXPR)
                     && FLOAT_TYPE_P (TREE_TYPE (rhs))))
               || (rhs_code == PLUS_EXPR && rhs_def_code == MINUS_EXPR)
               || (rhs_code == MINUS_EXPR && rhs_def_code == PLUS_EXPR))
...

- fariborz


-- Gaby



More information about the Gcc mailing list