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] Fix extract_range_from_cond (PR tree-optimization/19060)


On Fri, 7 Jan 2005, Jakub Jelinek wrote:
> 2005-01-07  Jakub Jelinek  <jakub@redhat.com>
>
> 	PR tree-optimization/19060
> 	* tree-ssa-dom.c (extract_range_from_cond) <case LT_EXPR, GT_EXPR>:
> 	Return 0 if op1 <= TYPE_MIN_VALUE () resp. op1 >= TYPE_MAX_VALUE ().
> 	(simplify_cond_and_lookup_avail_expr): Add assert for dummy == 0
> 	and handle extract_range_from_cond returning false.
> 	* fold-const.c (fold): Optimize comparisons with min/max even for
> 	width > HOST_BITS_PER_WIDE_INT.
>
> 	* gcc.c-torture/execute/20050104-1.c: New test.

This is OK for mainline, with one minor tweak...

> @@ -3216,8 +3226,10 @@ extract_range_from_cond (tree cond, tree
>        break;
>
>      case LT_EXPR:
> -      high = int_const_binop (MINUS_EXPR, op1, integer_one_node, 1);
>        low = TYPE_MIN_VALUE (type);
> +      if (tree_int_cst_equal (op1, low) || tree_int_cst_lt (op1, low))
> +	return 0;
> +      high = int_const_binop (MINUS_EXPR, op1, integer_one_node, 1);
>        inverted = 0;
>        break;

This new conditional is probably better written as

	if (!tree_int_cst_lt (low, op1))
	  return 0;


Many thanks for your bug fixing,

Roger
--


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