Bug 20657 - [tcb] VRP does not get rid of a redundant "if" statement.
Summary: [tcb] VRP does not get rid of a redundant "if" statement.
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: unknown
: P2 enhancement
Target Milestone: 4.1.0
Assignee: Kazu Hirata
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2005-03-27 19:41 UTC by Kazu Hirata
Modified: 2005-04-14 13:35 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-03-27 22:35:28


Attachments
Patch (331 bytes, text/plain)
2005-03-27 19:42 UTC, Kazu Hirata
Details

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

int
foo (int a)
{
  if (a == 0)
    if (a == 0)
      return 1;
  return 0;
}

Note that the second "if" statement is redundant.
Comment 1 Kazu Hirata 2005-03-27 19:42:41 UTC
Created attachment 8462 [details]
Patch
Comment 2 Andrew Pinski 2005-03-27 22:35:28 UTC
Confirmed.
Comment 3 Kazu Hirata 2005-04-14 13:07:59 UTC
Patch posted:
http://gcc.gnu.org/ml/gcc-patches/2005-04/msg01577.html
Comment 4 Kazu Hirata 2005-04-14 13:35:46 UTC
Just checked in a patch.
Comment 5 GCC Commits 2005-04-14 13:36:42 UTC
Subject: Bug 20657

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	kazu@gcc.gnu.org	2005-04-14 13:34:59

Modified files:
	gcc            : ChangeLog tree-vrp.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg/tree-ssa: pr20657.c 

Log message:
	gcc/
	PR tree-optimization/20657
	* tree-vrp.c (extract_range_from_expr): Notice INTEGER_CST to
	create an appropriate range from it.
	
	testsuite/
	PR tree-optimization/20657
	* gcc.dg/tree-ssa/pr20657.c: New.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.8286&r2=2.8287
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-vrp.c.diff?cvsroot=gcc&r1=2.6&r2=2.7
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5346&r2=1.5347
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/pr20657.c.diff?cvsroot=gcc&r1=NONE&r2=1.1