int foo (int i, int j) { if (i >= j) if (i != j) return 0; return -1; } should be optimized to if (i > j) return 0; return -1;
Mine.
Queued for 4.5.
Does this patch also solve PR 28685?
Subject: Re: if-combine doesn't optimize != after >= test On Sun, 12 Oct 2008, ubizjak at gmail dot com wrote: > Does this patch also solve PR 28685? No. ifcombine only combines on the CFG, in PR28685 we are dealing with a CFG-less opportunity. Richard.
Subject: Re: if-combine doesn't optimize != after >= test On Sun, Oct 12, 2008 at 1:40 PM, rguenther at suse dot de <gcc-bugzilla@gcc.gnu.org> wrote: > No. ifcombine only combines on the CFG, in PR28685 we are dealing > with a CFG-less opportunity. Well it depends really. As on some targets it has a CFG based ||/&& depending on BRANCH_COST. Thanks, Andrew Pinski
Subject: Re: if-combine doesn't optimize != after >= test On Sun, 12 Oct 2008, pinskia at gmail dot com wrote: > ------- Comment #5 from pinskia at gmail dot com 2008-10-12 20:47 ------- > Subject: Re: if-combine doesn't optimize != after >= test > > On Sun, Oct 12, 2008 at 1:40 PM, rguenther at suse dot de > <gcc-bugzilla@gcc.gnu.org> wrote: > > No. ifcombine only combines on the CFG, in PR28685 we are dealing > > with a CFG-less opportunity. > > Well it depends really. As on some targets it has a CFG based ||/&& > depending on BRANCH_COST. In that case we already optimize it. Richard.
Subject: Bug 37795 Author: rguenth Date: Sat Mar 28 10:01:56 2009 New Revision: 145170 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145170 Log: 2009-03-28 Richard Guenther <rguenther@suse.de> PR tree-optimization/37795 * tree.h (combine_comparisons): Declare. * fold-const.c (combine_comparisons): Export. * tree-ssa-ifcombine.c (ifcombine_ifandif): Optimize two successive comparisons. (ifcombine_iforif): Use combine_comparisons. * gcc.dg/tree-ssa/ssa-ifcombine-7.c: New testcase. Added: trunk/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-7.c Modified: trunk/gcc/ChangeLog trunk/gcc/fold-const.c trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-ssa-ifcombine.c trunk/gcc/tree.h
Fixed.