This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Fix fold-const breakage
- To: jakub at redhat dot com
- Subject: Re: [PATCH] Fix fold-const breakage
- From: kenner at vlsi1 dot ultra dot nyu dot edu (Richard Kenner)
- Date: Thu, 22 Feb 01 17:55:58 EST
- Cc: gcc-patches at gcc dot gnu dot org
The reason is that it is not safe to optimize:
( x * -3 - y * 3 ) / 12 into x / -4 - y / 4 which was extract_muldiv trying
(since extract_muldiv gave non-zero for both operands).
- if (t1 != 0 && t2 != 0)
+ if (t1 != 0 && t2 != 0
+ && (code == MULT_EXPR
+ /* If not multiplication, we can only this if both operands
+ are divisible by c. */
+ || (multiple_of_p (ctype, op0, c)
+ && multiple_of_p (ctype, op1, c))))
This is a pretty major pessimization of the code. Isn't there some finer
test that can be made here?
+ if (TYPE_PRECISION (TREE_TYPE (size_one_node))
+ > TREE_INT_CST_LOW (op1)
+ && TREE_INT_CST_HIGH (op1) == 0
This can be done with compare_tree_int.