Skip to content

Commit 5185274

Browse files
committed
rtl-ssa: Rework _ignoring interfaces
rtl-ssa has routines for scanning forwards or backwards for something under the control of an exclusion set. These searches are currently used for two main things: - to work out where an instruction can be moved within its EBB - to work out whether recog can add a new hard register clobber The exclusion set was originally a callback function that returned true for insns that should be ignored. However, for the late-combine work, I'd also like to be able to skip an entire definition, along with all its uses. This patch prepares for that by turning the exclusion set into an object that provides predicate member functions. Currently the only two member functions are: - should_ignore_insn: what the old callback did - should_ignore_def: the new functionality but more could be added later. Doing this also makes it easy to remove some asymmetry that I think in hindsight was a mistake: in forward scans, ignoring an insn meant ignoring all definitions in that insn (ok) and all uses of those definitions (non-obvious). The new interface makes it possible to select the required behaviour, with that behaviour being applied consistently in both directions. Now that the exclusion set is a dedicated object, rather than just a "random" function, I think it makes sense to remove the _ignoring suffix from the function names. The suffix was originally there to describe the callback, and in particular to emphasise that a true return meant "ignore" rather than "heed". gcc/ * rtl-ssa.h: Include predicates.h. * rtl-ssa/predicates.h: New file. * rtl-ssa/access-utils.h (prev_call_clobbers_ignoring): Rename to... (prev_call_clobbers): ...this and treat the ignore parameter as an object with the same interface as ignore_nothing. (next_call_clobbers_ignoring): Rename to... (next_call_clobbers): ...this and treat the ignore parameter as an object with the same interface as ignore_nothing. (first_nondebug_insn_use_ignoring): Rename to... (first_nondebug_insn_use): ...this and treat the ignore parameter as an object with the same interface as ignore_nothing. (last_nondebug_insn_use_ignoring): Rename to... (last_nondebug_insn_use): ...this and treat the ignore parameter as an object with the same interface as ignore_nothing. (last_access_ignoring): Rename to... (last_access): ...this and treat the ignore parameter as an object with the same interface as ignore_nothing. Conditionally skip definitions. (prev_access_ignoring): Rename to... (prev_access): ...this and treat the ignore parameter as an object with the same interface as ignore_nothing. (first_def_ignoring): Replace with... (first_access): ...this new function. (next_access_ignoring): Rename to... (next_access): ...this and treat the ignore parameter as an object with the same interface as ignore_nothing. Conditionally skip definitions. * rtl-ssa/change-utils.h (insn_is_changing): Delete. (restrict_movement_ignoring): Rename to... (restrict_movement): ...this and treat the ignore parameter as an object with the same interface as ignore_nothing. (recog_ignoring): Rename to... (recog): ...this and treat the ignore parameter as an object with the same interface as ignore_nothing. * rtl-ssa/changes.h (insn_is_changing_closure): Delete. * rtl-ssa/functions.h (function_info::add_regno_clobber): Treat the ignore parameter as an object with the same interface as ignore_nothing. * rtl-ssa/insn-utils.h (insn_is): Delete. * rtl-ssa/insns.h (insn_is_closure): Delete. * rtl-ssa/member-fns.inl (insn_is_changing_closure::insn_is_changing_closure): Delete. (insn_is_changing_closure::operator()): Likewise. (function_info::add_regno_clobber): Treat the ignore parameter as an object with the same interface as ignore_nothing. (ignore_changing_insns::ignore_changing_insns): New function. (ignore_changing_insns::should_ignore_insn): Likewise. * rtl-ssa/movement.h (restrict_movement_for_dead_range): Treat the ignore parameter as an object with the same interface as ignore_nothing. (restrict_movement_for_defs_ignoring): Rename to... (restrict_movement_for_defs): ...this and treat the ignore parameter as an object with the same interface as ignore_nothing. (restrict_movement_for_uses_ignoring): Rename to... (restrict_movement_for_uses): ...this and treat the ignore parameter as an object with the same interface as ignore_nothing. Conditionally skip definitions. * doc/rtl.texi: Update for above name changes. Use ignore_changing_insns instead of insn_is_changing. * config/aarch64/aarch64-cc-fusion.cc (cc_fusion::parallelize_insns): Likewise. * pair-fusion.cc (no_ignore): Delete. (latest_hazard_before, first_hazard_after): Update for above name changes. Use ignore_nothing instead of no_ignore. (pair_fusion_bb_info::fuse_pair): Update for above name changes. Use ignore_changing_insns instead of insn_is_changing. (pair_fusion::try_promote_writeback): Likewise.
1 parent ae13af2 commit 5185274

13 files changed

+275
-250
lines changed

gcc/config/aarch64/aarch64-cc-fusion.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ cc_fusion::parallelize_insns (def_info *cc_def, rtx cc_set,
183183
auto other_change = insn_change::delete_insn (other_insn);
184184
insn_change *changes[] = { &other_change, &cc_change };
185185
cc_change.move_range = cc_insn->ebb ()->insn_range ();
186-
if (!restrict_movement_ignoring (cc_change, insn_is_changing (changes)))
186+
if (!restrict_movement (cc_change, ignore_changing_insns (changes)))
187187
{
188188
if (dump_file && (dump_flags & TDF_DETAILS))
189189
fprintf (dump_file, "-- cannot satisfy all definitions and uses\n");
@@ -205,7 +205,7 @@ cc_fusion::parallelize_insns (def_info *cc_def, rtx cc_set,
205205
validate_change (cc_rtl, &PATTERN (cc_rtl), m_parallel, 1);
206206

207207
// These routines report failures themselves.
208-
if (!recog_ignoring (attempt, cc_change, insn_is_changing (changes))
208+
if (!recog (attempt, cc_change, ignore_changing_insns (changes))
209209
|| !changes_are_worthwhile (changes)
210210
|| !crtl->ssa->verify_insn_changes (changes))
211211
return false;

gcc/doc/rtl.texi

+7-7
Original file line numberDiff line numberDiff line change
@@ -5073,7 +5073,7 @@ in the correct order with respect to each other.
50735073
The way to do this is:
50745074

50755075
@smallexample
5076-
if (!rtl_ssa::restrict_movement_ignoring (change, insn_is_changing (changes)))
5076+
if (!rtl_ssa::restrict_movement (change, ignore_changing_insns (changes)))
50775077
return false;
50785078
@end smallexample
50795079

@@ -5085,7 +5085,7 @@ changing instructions (which might, for example, no longer need
50855085
to clobber the flags register). The way to do this is:
50865086

50875087
@smallexample
5088-
if (!rtl_ssa::recog_ignoring (attempt, change, insn_is_changing (changes)))
5088+
if (!rtl_ssa::recog (attempt, change, ignore_changing_insns (changes)))
50895089
return false;
50905090
@end smallexample
50915091

@@ -5137,16 +5137,16 @@ change2.move_range = @dots{};
51375137
51385138
rtl_ssa::insn_change *changes[] = @{ &change1, &change2 @};
51395139
5140-
auto is_changing = insn_is_changing (changes);
5141-
if (!rtl_ssa::restrict_movement_ignoring (change1, is_changing)
5142-
|| !rtl_ssa::restrict_movement_ignoring (change2, is_changing))
5140+
auto ignore = ignore_changing_insns (changes);
5141+
if (!rtl_ssa::restrict_movement (change1, ignore)
5142+
|| !rtl_ssa::restrict_movement (change2, ignore))
51435143
return false;
51445144
51455145
insn_change_watermark watermark;
51465146
// Use validate_change etc. to change INSN1's and INSN2's patterns.
51475147
@dots{}
5148-
if (!rtl_ssa::recog_ignoring (attempt, change1, is_changing)
5149-
|| !rtl_ssa::recog_ignoring (attempt, change2, is_changing)
5148+
if (!rtl_ssa::recog (attempt, change1, ignore)
5149+
|| !rtl_ssa::recog (attempt, change2, ignore)
51505150
|| !rtl_ssa::changes_are_worthwhile (changes)
51515151
|| !crtl->ssa->verify_insn_changes (changes))
51525152
return false;

gcc/pair-fusion.cc

+14-20
Original file line numberDiff line numberDiff line change
@@ -563,9 +563,6 @@ pair_fusion_bb_info::track_access (insn_info *insn, bool load_p, rtx mem)
563563
}
564564
}
565565

566-
// Dummy predicate that never ignores any insns.
567-
static bool no_ignore (insn_info *) { return false; }
568-
569566
// Return the latest dataflow hazard before INSN.
570567
//
571568
// If IGNORE is non-NULL, this points to a sub-rtx which we should ignore for
@@ -643,9 +640,8 @@ latest_hazard_before (insn_info *insn, rtx *ignore,
643640
if (!call_group->clobbers (def->resource ()))
644641
continue;
645642

646-
auto clobber_insn = prev_call_clobbers_ignoring (*call_group,
647-
def->insn (),
648-
no_ignore);
643+
auto clobber_insn = prev_call_clobbers (*call_group, def->insn (),
644+
ignore_nothing ());
649645
if (clobber_insn)
650646
hazard (clobber_insn);
651647
}
@@ -704,9 +700,8 @@ first_hazard_after (insn_info *insn, rtx *ignore)
704700
if (!call_group->clobbers (def->resource ()))
705701
continue;
706702

707-
auto clobber_insn = next_call_clobbers_ignoring (*call_group,
708-
def->insn (),
709-
no_ignore);
703+
auto clobber_insn = next_call_clobbers (*call_group, def->insn (),
704+
ignore_nothing ());
710705
if (clobber_insn)
711706
hazard (clobber_insn);
712707
}
@@ -733,16 +728,15 @@ first_hazard_after (insn_info *insn, rtx *ignore)
733728

734729
// Also need to handle call clobbers of our uses (again WaR).
735730
//
736-
// See restrict_movement_for_uses_ignoring for why we don't
737-
// need to check backwards for call clobbers.
731+
// See restrict_movement_for_uses for why we don't need to check
732+
// backwards for call clobbers.
738733
for (auto call_group : use->ebb ()->call_clobbers ())
739734
{
740735
if (!call_group->clobbers (use->resource ()))
741736
continue;
742737

743-
auto clobber_insn = next_call_clobbers_ignoring (*call_group,
744-
use->insn (),
745-
no_ignore);
738+
auto clobber_insn = next_call_clobbers (*call_group, use->insn (),
739+
ignore_nothing ());
746740
if (clobber_insn)
747741
hazard (clobber_insn);
748742
}
@@ -1965,12 +1959,12 @@ pair_fusion_bb_info::fuse_pair (bool load_p,
19651959
}
19661960
}
19671961

1968-
auto is_changing = insn_is_changing (changes);
1962+
auto ignore = ignore_changing_insns (changes);
19691963
for (unsigned i = 0; i < changes.length (); i++)
1970-
gcc_assert (rtl_ssa::restrict_movement_ignoring (*changes[i], is_changing));
1964+
gcc_assert (rtl_ssa::restrict_movement (*changes[i], ignore));
19711965

19721966
// Check the pair pattern is recog'd.
1973-
if (!rtl_ssa::recog_ignoring (attempt, *pair_change, is_changing))
1967+
if (!rtl_ssa::recog (attempt, *pair_change, ignore))
19741968
{
19751969
if (dump_file)
19761970
fprintf (dump_file, " failed to form pair, recog failed\n");
@@ -2953,11 +2947,11 @@ pair_fusion::try_promote_writeback (insn_info *insn, bool load_p)
29532947
pair_change.new_defs);
29542948
gcc_assert (pair_change.new_defs.is_valid ());
29552949

2956-
auto is_changing = insn_is_changing (changes);
2950+
auto ignore = ignore_changing_insns (changes);
29572951
for (unsigned i = 0; i < ARRAY_SIZE (changes); i++)
2958-
gcc_assert (rtl_ssa::restrict_movement_ignoring (*changes[i], is_changing));
2952+
gcc_assert (rtl_ssa::restrict_movement (*changes[i], ignore));
29592953

2960-
if (!rtl_ssa::recog_ignoring (attempt, pair_change, is_changing))
2954+
if (!rtl_ssa::recog (attempt, pair_change, ignore))
29612955
{
29622956
if (dump_file)
29632957
fprintf (dump_file, "i%d: recog failed on wb pair, bailing out\n",

gcc/rtl-ssa.h

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
#include "rtl-ssa/blocks.h"
6464
#include "rtl-ssa/changes.h"
6565
#include "rtl-ssa/functions.h"
66+
#include "rtl-ssa/predicates.h"
6667
#include "rtl-ssa/is-a.inl"
6768
#include "rtl-ssa/access-utils.h"
6869
#include "rtl-ssa/insn-utils.h"

0 commit comments

Comments
 (0)