This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [ PATCH ] Split out my fold-const.c change and add a test case
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Robert Kennedy <jimbob at google dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 04 Jan 2007 21:12:57 -0800
- Subject: Re: [ PATCH ] Split out my fold-const.c change and add a test case
- References: <17821.46538.761358.123421@whippen.corp.google.com>
Robert Kennedy wrote:
> 2007-01-04 Robert Kennedy <jimbob@google.com>
> * fold-const.c (fold_comparison): Fold comparisons like (x *
> 1000 < 0) to (x < 0).
> * fold-compare-2.c: New test case for fold_comparison.
> + /* Transform comparisons of the form X * C1 CMP 0 to X CMP 0 in the
> + signed arithmetic case. That form is created by the compiler
> + often enough for folding it to be of value. One example is in
> + computing loop trip counts after Operator Strength Reduction. */
> + if (!(flag_wrapv || flag_trapv)
> + && !TYPE_UNSIGNED (TREE_TYPE (arg0))
> + && TREE_CODE (arg0) == MULT_EXPR
> + && (TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST
> + && !TREE_OVERFLOW (TREE_OPERAND (arg0, 1)))
> + && integer_zerop (arg1))
> + {
> + tree const1 = TREE_OPERAND (arg0, 1);
Would you please add:
gcc_assert (!integer_zerop (const1))
?
I'm assuming that you know at this point const1 can never be zero,
because of something somewhere else in this function or in the compiler,
as otherwise the optimization would of course be invalid.
Thanks,
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713