| Summary: | [4.3 regression] miscompilation at -O2 | ||
|---|---|---|---|
| Product: | gcc | Reporter: | Joost VandeVondele <Joost.VandeVondele> |
| Component: | tree-optimization | Assignee: | Not yet assigned to anyone <unassigned> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | dberlin, gcc-bugs, pinskia |
| Priority: | P3 | Keywords: | wrong-code |
| Version: | 4.3.0 | ||
| Target Milestone: | 4.3.0 | ||
| Host: | Target: | ||
| Build: | Known to work: | 4.2.1 | |
| Known to fail: | 4.3.0 | Last reconfirmed: | 2007-07-03 08:31:53 |
| Bug Depends on: | |||
| Bug Blocks: | 29975 | ||
|
Description
Joost VandeVondele
2007-07-03 07:20:40 UTC
Confirmed, introduced by revision 129146: Author: dberlin Date: Sat Jun 30 14:15:26 2007 New Revision: 126149 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=126149 Log: 2007-06-30 Daniel Berlin <dberlin@dberlin.org> Fix PR tree-optimization/32540 Fix PR tree-optimization/31651 * tree-ssa-sccvn.c: New file. * tree-ssa-sccvn.h: Ditto. * tree-vn.c: Include tree-ssa-sccvn.h ... I don't see anything obvious in the diff between before FRE and after, likewise for PRE. (In reply to comment #2) > I don't see anything obvious in the diff between before FRE and after, likewise > for PRE. gfortran -O1 -fno-tree-fre pr32604.f90 ./a.out 1.00000000000000 gfortran -O2 pr32604.f90 ./a.out 0.00000000000000 gfortran -O2 -fno-tree-pre pr32604.f90 ./a.out 1.00000000000000 gfortran -O2 -fno-tree-fre pr32604.f90 ./a.out 0.00000000000000 possibly related to http://gcc.gnu.org/ml/gcc/2007-07/msg00037.html The *.pre dump is clearly wrong:
pretmp.53_53 = *order_p_25(D);
<bb 7>:
# prephitmp.45_125 = PHI <storetmp.41_94(20), storetmp.41_92(21)>
...
D.1445_69 = pretmp.53_53;
storetmp.41_92 = D.1445_69;
*order_p_25(D) = D.1445_69;
i_71 = i_2 + 1;
if (i_2 == D.1401_27)
goto <bb 11>;
else
goto <bb 21>;
<bb 21>:
goto <bb 7>;
i.e. *order_p won't ever change in the loop.
Before *.pre it was changes correctly:
...
<bb 7>:
# i_2 = PHI <1(20), i_71(21)>
D.1421_29 = *order_p_25(D);
...
D.1439_48 = (*D.1423_32)[D.1438_47];
D.1440_49 = D.1421_29 + D.1439_48;
D.1441_64 = D.1435_44 * 2;
D.1442_65 = D.1441_64 + D.1437_46;
D.1443_67 = D.1442_65 + D.1434_43;
D.1444_68 = (*D.1423_32)[D.1443_67];
D.1445_69 = D.1440_49 - D.1444_68;
*order_p_25(D) = D.1445_69;
i_71 = i_2 + 1;
if (i_2 == D.1401_27)
goto <bb 11>;
else
goto <bb 21>;
<bb 21>:
goto <bb 7>;
Subject: Re: [4.3 regression] miscompilation at -O2 > D.1445_69 = pretmp.53_53; > storetmp.41_92 = D.1445_69; > *order_p_25(D) = D.1445_69; > i_71 = i_2 + 1; > if (i_2 == D.1401_27) > goto <bb 11>; > else > goto <bb 21>; > > <bb 21>: > goto <bb 7>; > > i.e. *order_p won't ever change in the loop. Actually, what it has really done is prove the load and store that happens have the same value. It happens to also decide that this value (D.1445_69) is invariant. This is the broken part, and it is because of antic_safe_loads not checking whether the operands of the load change. Subject: Bug 32604 Author: dberlin Date: Wed Jul 4 22:11:14 2007 New Revision: 126338 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=126338 Log: 2007-07-04 Daniel Berlin <dberlin@dberlin.org> PR tree-optimization/32604 PR tree-optimization/32606 * tree-ssa-pre.c (bb_bitmap_sets): Removed antic_safe_loads. (compute_antic_safe): Removed. (ANTIC_SAFE_LOADS): Ditto. (compute_antic_aux): Don't print ANTIC_SAFE_LOADS. (execute_pre): Don't call compute_antic_safe. (vuse_equiv): New function. (make_values_for_stmt): Use it * tree-ssa-sccvn.c (set_ssa_val_to): Remove assert, since it is not always true. Added: trunk/gcc/testsuite/gcc.c-torture/compile/pr32606.c trunk/gcc/testsuite/gfortran.fortran-torture/execute/pr32604.f90 Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-ssa-pre.c trunk/gcc/tree-ssa-sccvn.c Fixed. |