------- Additional Comments From trt at acm dot org  2005-05-18 17:21 -------
This is because fold-const.c only does ad-hoc re-association.
Here is an example for fold_truthop (approx line 8805)

      /* Check for the possibility of merging component references.  If our
         lhs is another similar operation, try to merge its rhs with our
         rhs.  Then try to merge our lhs and rhs.  */
      if (TREE_CODE (arg0) == code
          && 0 != (tem = fold_truthop (code, type,
                                       TREE_OPERAND (arg0, 1), arg1)))
        return fold_build2 (code, type, TREE_OPERAND (arg0, 0), tem);

A similar hack could be done for fold_range_test.

(I wrote a helper fold_assoc (f, x, code, type, op1, op2) that does this in a
more general way, but it in turn needed `find_assoc_p' and `commutes_p'
functions, and handling EXPR_MINUS was onerous.  It might be too slow for
general use.  Basically, it needs a fast way to check for common subexpressions
to avoid pointless recursions.)

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21643

Reply via email to