This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, middle-end]: Fix PR tree-optimization/{31966, 32533}


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?

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.

Uros.

Attachment: pr31966.diff.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]