This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/21643] GCC fails to merge ranges in comparison.
- From: "trt at acm dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 May 2005 17:21:36 -0000
- Subject: [Bug tree-optimization/21643] GCC fails to merge ranges in comparison.
- References: <20050518123222.21643.dwmw2@infradead.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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