This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/21001] New: VRP is weak when the tested variable in a COND_EXPR is used in the COND_EXPR.
- From: "kazu at cs dot umass dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 Apr 2005 19:05:46 -0000
- Subject: [Bug tree-optimization/21001] New: VRP is weak when the tested variable in a COND_EXPR is used in the COND_EXPR.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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