This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] PR 168: More tree_expr_nonnegative_p improvements


Roger Sayle <roger@eyesopen.com> writes:

> Many thanks to Joseph Myers for bringing it to my attention that
> the long-standing PR middle-end/168 is caused by a defficiency of
> GCC's tree_expr_nonnegative_p.  This patch contains several small
> improvements to tree_expr_nonnegative_p, which include recognizing
> that floating point conversions and the ceil and floor builtins are
> always sign preserving, that a zero extension is always non-negative,
> and that sign extension of a non-negative operand is non-negative.
> 
> Additionally, to actually fix PR middle-end/168, it now knows that
> zero_extend(x) + zero_extend(y) and zero_extend(x) * zero_extend(y)
> are unsigned, iff the result isn't wide enough to overflow into the
> sign bit of the result, using x+y is atmost max(bits(x),bits(y))+1
> wide, and x*y is atmost bits(x)+bits(y) wide.
> 
> The following patch has been tested on i686-pc-linux-gnu with a full
> "make bootstrap", all languages except treelang, and regression tested
> with a top-level "make -k check" with no new failures.
> 
> Ok for mainline?

OK.

> 
> 2003-06-12  Roger Sayle  <roger@eyesopen.com>
> 
> 	PR middle-end/168
> 	* fold-const.c (tree_expr_nonnegative_p):  Handle addition
> 	and multiplication of zero extensions, floating point division,
> 	and integer<->fp, fp<->fp and zero extension conversions.
> 	The built-in ceil and floor functions preserve signedness.
> 
> 	* gcc.dg/20030612-1.c: New test case.
-- 
- Geoffrey Keating <geoffk@geoffk.org>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]