Commit c05ffc49 by Bernd Schmidt Committed by Bernd Schmidt

Enhancements for the if-conversion pass

From-SVN: r55624
parent 753e29b1
2002-07-21 Bernd Schmidt <bernds@redhat.com>
Improvements for the ifcvt pass from Michael Meissner, with patches
by Richard Sandiford <rsandifo@redhat.com>
* basic-block.h (struct ce_if_block, ce_if_block_t): New types.
* ifcvt.c (cond_exec_changed_p): New static variable.
(last_active_insn): New function, renamed from last_active_insn_p
and changed to return the last active insn in a basic block. All
callers updated.
(block_fallthru): New function.
(cond_exec_process_insns): New argument CE_INFO. Pass it to
IFCVT_MODIFY_INSN. All callers updated.
Return false if START or END are NULL.
Handle case where we're processing an insn that is already
conditional.
(noce_process_if_block): CE_INFO argument rather than
multiple args containing the involved basic blocks. All callers
changed.
(process_if_block, merge_if_block, find_if_block,
cond_exec_process_if_block): Likewise.
(cond_exec_process_if_block): New arg DO_MULTIPLE_P. All callers
changed.
Use new function last_active_insn to simplify some code.
New code to handle multiple tests.
Call IFCVT_MODIFY_CANCEL in all failure cases, otherwise set
cond_exec_changed_p to TRUE.
(process_if_block): New code to handle multiple tests.
(merge_if_block): Likewise.
(find_if_header): New arg PASS. Changed to return the currently
processed basic block or NULL instead of true/false. All callers
changed.
Call IFCVT_INIT_EXTRA_FIELDS.
(block_jumps_and_fallthru_p): New function.
(find_if_block): Discover opportunities to convert multiple tests.
Add additional debugging output.
Update the ce_info structure before returning.
(if_convert): Run multiple passes of if-conversion.
* doc/tm.texi (IFCVT_MODIFY_TESTS, IFCVT_MODIFY_INSN,
IFCVT_MODIFY_FINAL, IFCVT_MODIFY_CANCEL, IFCVT_MODIFY_MULTIPLE_TESTS,
IFCVT_INIT_EXTRA_FIELDS, IFCVT_EXTRA_FIELDS): Update documentation for
these macros.
Sun Jul 21 00:54:54 CEST 2002 Jan Hubicka <jh@suse.cz> Sun Jul 21 00:54:54 CEST 2002 Jan Hubicka <jh@suse.cz>
* gcse.c: Include cselib.h * gcse.c: Include cselib.h
......
...@@ -523,6 +523,33 @@ struct loops ...@@ -523,6 +523,33 @@ struct loops
sbitmap shared_headers; sbitmap shared_headers;
}; };
/* Structure to group all of the information to process IF-THEN and
IF-THEN-ELSE blocks for the conditional execution support. This
needs to be in a public file in case the IFCVT macros call
functions passing the ce_if_block data structure. */
typedef struct ce_if_block
{
basic_block test_bb; /* First test block. */
basic_block then_bb; /* THEN block. */
basic_block else_bb; /* ELSE block or NULL. */
basic_block join_bb; /* Join THEN/ELSE blocks. */
basic_block last_test_bb; /* Last bb to hold && or || tests. */
int num_multiple_test_blocks; /* # of && and || basic blocks. */
int num_and_and_blocks; /* # of && blocks. */
int num_or_or_blocks; /* # of || blocks. */
int num_multiple_test_insns; /* # of insns in && and || blocks. */
int and_and_p; /* Complex test is &&. */
int num_then_insns; /* # of insns in THEN block. */
int num_else_insns; /* # of insns in ELSE block. */
int pass; /* Pass number. */
#ifdef IFCVT_EXTRA_FIELDS
IFCVT_EXTRA_FIELDS /* Any machine dependent fields. */
#endif
} ce_if_block_t;
extern int flow_loops_find PARAMS ((struct loops *, int flags)); extern int flow_loops_find PARAMS ((struct loops *, int flags));
extern int flow_loops_update PARAMS ((struct loops *, int flags)); extern int flow_loops_update PARAMS ((struct loops *, int flags));
extern void flow_loops_free PARAMS ((struct loops *)); extern void flow_loops_free PARAMS ((struct loops *));
......
...@@ -8813,29 +8813,54 @@ conditional execution instructions instead of a branch. A value of ...@@ -8813,29 +8813,54 @@ conditional execution instructions instead of a branch. A value of
1 if it does use cc0. 1 if it does use cc0.
@findex IFCVT_MODIFY_TESTS @findex IFCVT_MODIFY_TESTS
@item IFCVT_MODIFY_TESTS @item IFCVT_MODIFY_TESTS(@var{ce_info}, @var{true_expr}, @var{false_expr})
A C expression to modify the tests in @code{TRUE_EXPR}, and Used if the target needs to perform machine-dependent modifications on the
@code{FALSE_EXPR} for use in converting insns in @code{TEST_BB}, conditionals used for turning basic blocks into conditionally executed code.
@code{THEN_BB}, @code{ELSE_BB}, and @code{JOIN_BB} basic blocks to @var{ce_info} points to a data structure, @code{struct ce_if_block}, which
conditional execution. Set either @code{TRUE_EXPR} or @code{FALSE_EXPR} contains information about the currently processed blocks. @var{true_expr}
to a null pointer if the tests cannot be converted. and @var{false_expr} are the tests that are used for converting the
then-block and the else-block, respectively. Set either @var{true_expr} or
@var{false_expr} to a null pointer if the tests cannot be converted.
@findex IFCVT_MODIFY_MULTIPLE_TESTS
@item IFCVT_MODIFY_MULTIPLE_TESTS(@var{ce_info}, @var{bb}, @var{true_expr}, @var{false_expr})
Like @code{IFCVT_MODIFY_TESTS}, but used when converting more complicated
if-statements into conditions combined by @code{and} and @code{or} operations.
@var{bb} contains the basic block that contains the test that is currently
being processed and about to be turned into a condition.
@findex IFCVT_MODIFY_INSN @findex IFCVT_MODIFY_INSN
@item IFCVT_MODIFY_INSN @item IFCVT_MODIFY_INSN(@var{ce_info}, @var{pattern}, @var{insn})
A C expression to modify the @code{PATTERN} of an @code{INSN} that is to A C expression to modify the @var{PATTERN} of an @var{INSN} that is to
be converted to conditional execution format. be converted to conditional execution format. @var{ce_info} points to
a data structure, @code{struct ce_if_block}, which contains information
about the currently processed blocks.
@findex IFCVT_MODIFY_FINAL @findex IFCVT_MODIFY_FINAL
@item IFCVT_MODIFY_FINAL @item IFCVT_MODIFY_FINAL(@var{ce_info})
A C expression to perform any final machine dependent modifications in A C expression to perform any final machine dependent modifications in
converting code to conditional execution in the basic blocks converting code to conditional execution. The involved basic blocks
@code{TEST_BB}, @code{THEN_BB}, @code{ELSE_BB}, and @code{JOIN_BB}. can be found in the @code{struct ce_if_block} structure that is pointed
to by @var{ce_info}.
@findex IFCVT_MODIFY_CANCEL @findex IFCVT_MODIFY_CANCEL
@item IFCVT_MODIFY_CANCEL @item IFCVT_MODIFY_CANCEL(@var{ce_info})
A C expression to cancel any machine dependent modifications in A C expression to cancel any machine dependent modifications in
converting code to conditional execution in the basic blocks converting code to conditional execution. The involved basic blocks
@code{TEST_BB}, @code{THEN_BB}, @code{ELSE_BB}, and @code{JOIN_BB}. can be found in the @code{struct ce_if_block} structure that is pointed
to by @var{ce_info}.
@findex IFCVT_INIT_EXTRA_FIELDS
@item IFCVT_INIT_EXTRA_FIELDS(@var{ce_info})
A C expression to initialize any extra fields in a @code{struct ce_if_block}
structure, which are defined by the @code{IFCVT_EXTRA_FIELDS} macro.
@findex IFCVT_EXTRA_FIELDS
@item IFCVT_EXTRA_FIELDS
If defined, it should expand to a set of field declarations that will be
added to the @code{struct ce_if_block} structure. These should be intialized
by the @code{IFCVT_INIT_EXTRA_FIELDS} macro.
@end table @end table
@deftypefn {Target Hook} void TARGET_INIT_BUILTINS () @deftypefn {Target Hook} void TARGET_INIT_BUILTINS ()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment