This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] Fix tree-optimization/20139.
- From: Jeffrey A Law <law at redhat dot com>
- To: Kazu Hirata <kazu at cs dot umass dot edu>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 23 Feb 2005 10:00:53 -0700
- Subject: Re: [patch] Fix tree-optimization/20139.
- Organization: Red Hat, Inc
- References: <20050222.205231.118631279.kazu@cs.umass.edu>
- Reply-to: law at redhat dot com
On Tue, 2005-02-22 at 20:52 -0500, Kazu Hirata wrote:
> Hi,
>
> Attached is a patch to fix tree-optimization/20139.
>
> Consider the attached testcase.
>
> TER changes
>
> p_2 = ABS_EXPR <x_1>;
> if (p_2 < 0.0) goto <L0>; else goto <L1>;
>
> into
>
> if (ABS_EXPR <x> < 0.0) goto <L0>; else goto <L1>;
>
> which would get folded by fold in find_taken_edge, which I recently
> removed, causing a missed optimization at tree level.
>
> The patch essentially restores fold for the last run of
> cleanup_tree_cfg by running fold_cond_expr_cond immediately before
> cleanup_tree_cfg.
>
> IMHO, the right thing to do is to propagate the range of ABS_EXPR's
> result, and fold the "if" statement accordingly. I hope this patch
> will be reverted in 4.1 once we start doing a good VRP.
>
> Some people are for removing gcc.c-torture/execute/20020720-1.c as the
> testcase in this patch will be stronger in that it checks that "if" is
> gone at tree level. Others don't see a reason for removing the old
> testcase. Personally, I can go with either option.
>
> Tested on i686-pc-linux-gnu. OK to apply?
>
> Kazu Hirata
>
> 2005-02-22 Kazu Hirata <kazu@cs.umass.edu>
>
> PR tree-optimization/20139
> * tree-cfg.c (fold_cond_expr_cond): Export.
> * tree-flow.h: Add a prototype for fold_cond_expr_cond.
> * tree-optimize.c (execute_cleanup_cfg_post_optimizing): Call
> fold_cond_expr_cond.
>
> 2005-02-22 Kazu Hirata <kazu@cs.umass.edu>
>
> PR tree-optimization/20139
> * gcc.dg/tree-ssa/pr20139.c: New.
FWIW, we might consider just folding any expression that is subject
to TER. I've got a patch somewhere around here which does that.
Mostly it seems to eliminate casts, but from time to time it finds
something it can zap in complex expressions.
Thoughts?
jeff