[Bug tree-optimization/21367] New: VRP does not fold "if (a == b)" in a certain situation
kazu at cs dot umass dot edu
gcc-bugzilla@gcc.gnu.org
Tue May 3 19:33:00 GMT 2005
Consider
int
foo (int a, int b)
{
if (a == b)
if (a == b)
return 123;
return 0;
}
With -fno-tree-dominator-opts -fdump-tree-vrp-details, VRP does not fold
the second "if" statement. Here is what I get from VRP.
Value ranges after VRP:
D.1234_1: VARYING
a_2: VARYING
b_3: VARYING
<retval>_4: VARYING
D.1234_5: [0, 0]
D.1234_6: [123, 123]
a_7: [b_3, b_3]
a_8: ~[b_3, b_3]
foo (a, b)
{
int D.1234;
<bb 0>:
if (a_2 == b_3) goto <L0>; else goto <L5>;
<L0>:;
a_7 = b_3;
if (a_7 == b_3) goto <L1>; else goto <L2>;
<L1>:;
D.1234_6 = 123;
goto <bb 5> (<L4>);
<L5>:;
a_8 = a_2;
<L2>:;
D.1234_5 = 0;
# D.1234_1 = PHI <D.1234_6(2), D.1234_5(4)>;
<L4>:;
return D.1234_1;
}
Note that we have
b_3: VARYING
a_7: [b_3, b_3]
so we have enough information to fold the second "if" statement despite
the fact that b_3 is VARYING.
--
Summary: VRP does not fold "if (a == b)" in a certain situation
Product: gcc
Version: unknown
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: enhancement
Priority: P2
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: kazu at cs dot umass dot edu
CC: dnovillo at redhat dot com,gcc-bugs at gcc dot gnu dot
org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21367
More information about the Gcc-bugs
mailing list