GCC Middle and Back End API Reference
|
Data Structures | |
struct | comparison_use |
struct | comparison |
class | find_comparison_dom_walker |
Typedefs | |
typedef struct comparison * | comparison_struct_p |
Functions | |
static rtx | conforming_compare () |
static bool | arithmetic_flags_clobber_p () |
static void | find_flags_uses_in_insn () |
static void | find_comparisons () |
static rtx | maybe_select_cc_mode (struct comparison *cmp, rtx a, rtx b) |
static bool | try_eliminate_compare () |
static unsigned int | execute_compare_elim_after_reload () |
static bool | gate_compare_elim_after_reload () |
rtl_opt_pass * | make_pass_compare_elim_after_reload () |
Variables | |
static vec< comparison_struct_p > | all_compares |
typedef struct comparison* comparison_struct_p |
|
static |
Look for a pattern of the "correct" form for an insn with a flags clobber for which we may be able to eliminate a compare later. We're not looking to validate any inputs at this time, merely see that the basic shape is correct. The term "arithmetic" may be somewhat misleading...
References targetm.
|
static |
Look for a "conforming" comparison, as defined above. If valid, return the rtx for the COMPARE itself.
|
static |
Main entry point to the pass.
Locate all comparisons and their uses, and eliminate duplicates.
Eliminate comparisons that are redundant with flags computation.
|
static |
Find all comparisons in the function.
|
static |
Look for uses of FLAGS in INSN. If we find one we can analyze, record it in CMP; otherwise indicate that we've missed a use.
If we've already lost track of uses, don't bother collecting more.
Find a USE of the flags register.
If this is an unusual use, quit.
If we've run out of slots to record uses, quit.
Unfortunately the location of the flags register, while present in the reference structure, doesn't help. We need to find the comparison code that is outer to the actual flags use.
We've found a use of the flags that we understand.
We failed to recognize this use of the flags register.
|
static |
Setting this target hook value is how a backend indicates the need.
rtl_opt_pass* make_pass_compare_elim_after_reload | ( | ) |
|
static |
Select an alternate CC_MODE for a comparison insn comparing A and B. Note that inputs are almost certainly different than the IN_A and IN_B stored in CMP -- we're called while attempting to eliminate the compare after all. Return the new FLAGS rtx if successful, else return NULL. Note that this function may start a change group.
Minimize code differences when this target macro is undefined.
If we don't have access to all of the uses, we can't validate.
Find a new mode that works for all of the uses. Special case the common case of exactly one use.
References gen_rtx_REG(), comparison_use::insn, comparison_use::loc, targetm, comparison::uses, and validate_change().
|
static |
Attempt to replace a comparison with a prior arithmetic insn that can compute the same flags value as the comparison itself. Return true if successful, having made all rtl modifications necessary.
We must have found an interesting "clobber" preceding the compare.
??? For the moment we don't handle comparisons for which IN_B is a register. We accepted these during initial comparison recognition in order to eliminate duplicate compares. An improvement here would be to handle x = a - b; if (a cmp b).
Verify that IN_A is not clobbered in between CMP and PREV_CLOBBER. Given that this target requires this pass, we can assume that most insns do clobber the flags, and so the distance between the compare and the clobber is likely to be small.
??? This is one point at which one could argue that DF_REF_CHAIN would be useful, but it is thought to be too heavy-weight a solution here.
Note that the BB_HEAD is always either a note or a label, but in any case it means that IN_A is defined outside the block.
Find a possible def of IN_A in INSN.
No definitions of IN_A; continue searching.
Bail if this is not a totally normal set of IN_A.
We've found an insn between the compare and the clobber that sets IN_A. Given that pass_cprop_hardreg has not yet run, we still find situations in which we can usefully look through a copy insn.
We've reached PREV_CLOBBER without finding a modification of IN_A. Validate that PREV_CLOBBER itself does in fact refer to IN_A. Do recall that we've already validated the shape of PREV_CLOBBER.
Also check operations with implicit extensions, e.g.: [(set (reg:DI) (zero_extend:DI (plus:SI (reg:SI)(reg:SI)))) (set (reg:CCZ flags) (compare:CCZ (plus:SI (reg:SI)(reg:SI)) (const_int 0)))]
Determine if we ought to use a different CC_MODE here.
Generate a new comparison for installation in the setter.
Succeed if the new instruction is valid. Note that we may have started a change group within maybe_select_cc_mode, therefore we must continue.
Success. Delete the compare insn...
... and any notes that are now invalid due to multiple sets.
|
static |