Bug 21258 - Teach VRP to pick up a constant from case label.
Summary: Teach VRP to pick up a constant from case label.
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: unknown
: P2 enhancement
Target Milestone: 4.3.0
Assignee: Richard Biener
URL:
Keywords: FIXME, missed-optimization
Depends on: 18373
Blocks:
  Show dependency treegraph
 
Reported: 2005-04-27 19:38 UTC by Kazu Hirata
Modified: 2007-04-13 10:23 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-04-11 13:17:38


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kazu Hirata 2005-04-27 19:38:03 UTC
Consider:

void bar (void);

void
foo (int a)
{
  switch (a)
    {
    case 4:
      if (a >= 3
	  && a <= 5)
	bar ();
    }
}

Note that we could remove the "if" statement, VRP does not catch this.

I think Diego already knows about this, but I think it's worth a PR so that
we don't forget.
Comment 1 Diego Novillo 2005-04-27 19:43:13 UTC
Subject: Re:  New: Teach VRP to pick up a constant from case label.

On Wed, Apr 27, 2005 at 07:38:04PM -0000, kazu at cs dot umass dot edu wrote:

> I think Diego already knows about this, but I think it's worth a PR so that
> we don't forget.
> 
Yes, there's a FIXME in tree-vrp.c about not handling
SWITCH_EXPR.  I agree it's worth having a PR for it.


Diego.
Comment 2 Andrew Pinski 2005-04-28 00:36:53 UTC
Confirmed, in a way PR 20514 is related.
Comment 3 Kazu Hirata 2005-04-28 05:45:22 UTC
I'm testing a patch.
Comment 4 Diego Novillo 2005-06-02 20:24:11 UTC
Kazu is not working on this anymore.
Comment 5 Diego Novillo 2006-03-10 16:07:48 UTC
Not working on this anymore.
Comment 6 Richard Biener 2007-04-11 13:17:38 UTC
Mine.
Comment 7 Steven Bosscher 2007-04-11 14:35:48 UTC
Watch Bug 14495 while you're at it.
Comment 8 Richard Biener 2007-04-11 14:55:17 UTC
Actually, that's very different.  This one is about missing ASSERT_EXPRs, the
other one is about simplifying SWITCH_EXPRs using the value range of the switch
argument.
Comment 9 Richard Biener 2007-04-13 10:21:36 UTC
Subject: Bug 21258

Author: rguenth
Date: Fri Apr 13 10:21:22 2007
New Revision: 123778

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123778
Log:
2007-04-13  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/21258
	* tree-vrp.c (compare_case_labels): New helper.
	(find_switch_asserts): New function.
	(find_assert_locations): Call it for SWITCH_EXPRs.

	* gcc.dg/tree-ssa/vrp34.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.dg/tree-ssa/vrp34.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-vrp.c

Comment 10 Richard Biener 2007-04-13 10:23:44 UTC
Fixed.