On 7/16/07, Richard Guenther <richard.guenther@gmail.com> wrote:
> On 7/2/07, Richard Guenther <richard.guenther@gmail.com> wrote:
> > On 7/2/07, Uros Bizjak <ubizjak@gmail.com> wrote:
> > > Hello!
> > >
> > > As described in great detail in PR 31966, Comment #7 and Comment #6,
> > > there is a nasty bug in tree-if-convert.c. When a bb with condition
> > > code directly feeds bb with a phi node, current implementation
> > > "forgets" to account for the condition for the branch that leads to
> > > the phi node [see PR for further explanation and for the proof].
> > >
> > > The patch fixes this by attaching a condition of true or false arm to
> > > relevant edge. When constructing equivalent condition for phi node,
> > > incoming edges are checked if there is a condition attached to them,
> > > and in this case equivalent condition is constructed by boolean AND of
> > > successor block predicate and edge condition.
> > >
> > > The patch has been checked on i686-pc-linux-gnu on gcc-41 and gcc-42
> > > branches, as well as mainline, for all default languages. It fixes two
> > > PRs and (as reported in PR32533) fixes a bunch of failing CP2K
> > > testcases.
> > >
> > > OK for mainline and 4.1 and 4.2 branch?
> >
> > This is ok. Please let it have a few days on mainline before committing
> > to the branches.
> >
> > Thanks,
> > Richard.
> >
> > > 2007-07-02 Uros Bizjak <ubizjak@gmail.com>
> > >
> > > PR tree-optimization/31966
> > > PR tree-optimization/32533
> > > * tree-if-conv.c (add_to_dst_predicate_list): Use "edge", not
> > > "basic_block" description as its third argument. Update function
> > > calls to get destination bb from "edge" argument. Save "cond" into
> > > aux field of the edge. Update prototype for changed arguments.
> > > (find_phi_replacement_condition): Operate on incoming edges, not
> > > on predecessor blocks. If there is a condition saved in the
> > > incoming edge aux field, AND it with incoming bb predicate.
> > > Return source bb of the first edge.
> > > (clean_predicate_lists): Clean aux field of outgoing node edges.
> > > (tree_if_conversion): Do not initialize cond variable. Move
> > > variable declaration into the loop.
> > > (replace_phi_with_cond_gimple_modify_stmt): Remove unneded
> > > initializations of new_stmt, arg0 and arg1 variables.
> > >
> > > testsuite/ChangeLog:
> > >
> > > 2007-07-02 Uros Bizjak <ubizjak@gmail.com>
> > >
> > > PR tree-optimization/31966
> > > PR tree-optimization/32533
> > > * gcc.dg/tree-ssa/pr31966.c: New runtime test.
> > > * gfortran.dg/pr32533.f90: Ditto.
>
> On the 4.2 branch the testcase for PR32533 ICEs:
>
> /abuild/rguenther/gcc-4_2-branch/gcc/testsuite/gfortran.dg/pr32533.f90:
> In function 't':^M
> /abuild/rguenther/gcc-4_2-branch/gcc/testsuite/gfortran.dg/pr32533.f90:6:
> error: incorrect sharing of tree nodes^M
> D.1370_44 = M.2D.1253_16 > 1;^M
> ^M
> M.2D.1253_16 > 1;^M
> ^M
> /abuild/rguenther/gcc-4_2-branch/gcc/testsuite/gfortran.dg/pr32533.f90:6:
> internal compiler error: verify_stmts failed^M
> Please submit a full bug report,^M
> with preprocessed source if appropriate.^M
> See <URL:http://gcc.gnu.org/bugs.html> for instructions.^M
Huh?
~/gcc-build-42/gcc/f951 -O2 -ftree-vectorize -ffast-math pr32533.f90
t MAIN__
Analyzing compilation unitPerforming interprocedural optimizations
Assembling functions:
t MAIN__
Execution times (seconds)
tree VRP : 0.00 ( 0%) usr 0.00 ( 0%) sys 0.01
(25%) wall 6 kB ( 1%) ggc
tree iv optimization : 0.01 (50%) usr 0.00 ( 0%) sys 0.00 (
0%) wall 11 kB ( 1%) ggc
dominance computation : 0.01 (50%) usr 0.00 ( 0%) sys 0.01
(25%) wall 0 kB ( 0%) ggc
TOTAL : 0.02 0.00 0.04
810 kB
Do I miss some special checking setting that uncovers this?
Could you perhaps check if adding unshare_expr() for the "cond" in
+ if (second_edge->aux)
+ *cond = build2 (TRUTH_AND_EXPR, boolean_type_node,
+ *cond, second_edge->aux);
Fixes this problem?