public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/21001] New: VRP is weak when the tested variable in a COND_EXPR is used in the COND_EXPR.
@ 2005-04-13 19:05 kazu at cs dot umass dot edu
  2005-04-13 22:47 ` [Bug tree-optimization/21001] " pinskia at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: kazu at cs dot umass dot edu @ 2005-04-13 19:05 UTC (permalink / raw)
  To: gcc-bugs

Consider:

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

With "-O2 -ftree-no-dominator-opts", VRP generates:

foo (a)
{
  int b;
  int D.1153;

<bb 0>:
  b_3 = a_2 != 0;
  if (b_3 != 0) goto <L0>; else goto <L2>;

<L0>:;
  if (a_2 != 0) goto <L1>; else goto <L2>;

<L1>:;
  D.1153_6 = 1;
  goto <bb 4> (<L4>);

<L2>:;
  D.1153_5 = 0;

  # D.1153_1 = PHI <D.1153_6(2), D.1153_5(3)>;
<L4>:;
  return D.1153_1;

}

Note that the second "if" statement is always true,
but VRP does not notice that.

Forward-propagating "a_2 != 0" into the first "if" statement will do
the desired optimization.

-- 
           Summary: VRP is weak when the tested variable in a COND_EXPR is
                    used in the COND_EXPR.
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P2
         Component: tree-optimization
        AssignedTo: kazu at cs dot umass dot edu
        ReportedBy: kazu at cs dot umass dot edu
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21001


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/21001] VRP is weak when the tested variable in a COND_EXPR is used in the COND_EXPR.
  2005-04-13 19:05 [Bug tree-optimization/21001] New: VRP is weak when the tested variable in a COND_EXPR is used in the COND_EXPR kazu at cs dot umass dot edu
@ 2005-04-13 22:47 ` pinskia at gcc dot gnu dot org
  2005-04-15 20:32 ` [Bug tree-optimization/21001] VRP is weak when the tested variable in a COND_EXPR is used only " kazu at cs dot umass dot edu
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-13 22:47 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-04-13 22:46 -------
Confirmed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-04-13 22:46:53
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21001


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/21001] VRP is weak when the tested variable in a COND_EXPR is used only in the COND_EXPR.
  2005-04-13 19:05 [Bug tree-optimization/21001] New: VRP is weak when the tested variable in a COND_EXPR is used in the COND_EXPR kazu at cs dot umass dot edu
  2005-04-13 22:47 ` [Bug tree-optimization/21001] " pinskia at gcc dot gnu dot org
@ 2005-04-15 20:32 ` kazu at cs dot umass dot edu
  2005-04-18  6:10 ` cvs-commit at gcc dot gnu dot org
  2005-04-18  6:11 ` kazu at cs dot umass dot edu
  3 siblings, 0 replies; 5+ messages in thread
From: kazu at cs dot umass dot edu @ 2005-04-15 20:32 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From kazu at cs dot umass dot edu  2005-04-15 20:32 -------
Patch posted:
http://gcc.gnu.org/ml/gcc-patches/2005-04/msg01770.html


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21001


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/21001] VRP is weak when the tested variable in a COND_EXPR is used only in the COND_EXPR.
  2005-04-13 19:05 [Bug tree-optimization/21001] New: VRP is weak when the tested variable in a COND_EXPR is used in the COND_EXPR kazu at cs dot umass dot edu
  2005-04-13 22:47 ` [Bug tree-optimization/21001] " pinskia at gcc dot gnu dot org
  2005-04-15 20:32 ` [Bug tree-optimization/21001] VRP is weak when the tested variable in a COND_EXPR is used only " kazu at cs dot umass dot edu
@ 2005-04-18  6:10 ` cvs-commit at gcc dot gnu dot org
  2005-04-18  6:11 ` kazu at cs dot umass dot edu
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-04-18  6:10 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-04-18 06:10 -------
Subject: Bug 21001

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	kazu@gcc.gnu.org	2005-04-18 06:10:45

Modified files:
	gcc            : ChangeLog tree-optimize.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg/tree-ssa: pr21001.c 

Log message:
	gcc/
	PR tree-optimization/21001
	* tree-optimize.c (init_tree_optimization_passes): Move the
	first pass_forwprop immediately before pass_vrp.
	
	testsuite/
	PR tree-optimization/21001
	* gcc.dg/tree-ssa/pr21001.c: New.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.8340&r2=2.8341
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-optimize.c.diff?cvsroot=gcc&r1=2.83&r2=2.84
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5361&r2=1.5362
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/pr21001.c.diff?cvsroot=gcc&r1=NONE&r2=1.1



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21001


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/21001] VRP is weak when the tested variable in a COND_EXPR is used only in the COND_EXPR.
  2005-04-13 19:05 [Bug tree-optimization/21001] New: VRP is weak when the tested variable in a COND_EXPR is used in the COND_EXPR kazu at cs dot umass dot edu
                   ` (2 preceding siblings ...)
  2005-04-18  6:10 ` cvs-commit at gcc dot gnu dot org
@ 2005-04-18  6:11 ` kazu at cs dot umass dot edu
  3 siblings, 0 replies; 5+ messages in thread
From: kazu at cs dot umass dot edu @ 2005-04-18  6:11 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From kazu at cs dot umass dot edu  2005-04-18 06:11 -------
Just checked in a patch.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.1.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21001


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-04-18  6:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-13 19:05 [Bug tree-optimization/21001] New: VRP is weak when the tested variable in a COND_EXPR is used in the COND_EXPR kazu at cs dot umass dot edu
2005-04-13 22:47 ` [Bug tree-optimization/21001] " pinskia at gcc dot gnu dot org
2005-04-15 20:32 ` [Bug tree-optimization/21001] VRP is weak when the tested variable in a COND_EXPR is used only " kazu at cs dot umass dot edu
2005-04-18  6:10 ` cvs-commit at gcc dot gnu dot org
2005-04-18  6:11 ` kazu at cs dot umass dot edu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).