Hello, I would like any opinion on a new testing idea for .rules dsl.
Backstory:
My recent topo-sort prove adventure got me thinking.
I spawned 3 issues about the exact same bug in 3 different unrelated parts of the codebase:
cmd/compile: amd64 CMOV* lowering rules depend on the values schedulecmd/compile: ppc64 MADDLD lowering rules depend on the values schedule
all of this because I dared to change a meaningless thing (schedule of values before the schedule pass).
The previous ordering wasn't thought through by anyone or good in any metric since it doesn't matter.
However ossification later, tests come to rely on it.
Idea:
In classic mode (what exists today) rewrite goes top down in the function and finds the first matching rule (again going down rule by rule).
Instead there would be a test mode where it finds all matching rules and executes all of them on it's own clone of the function.
Then repeat until no more rules can be applied.
This means rather than rewriting a single first match win path.
We would explore the graph of all possible rewrites.
The test would be considered to pass if there is a single definite end state no matter the path you take in the graph (excluding cycles).
Implementation wise it would be extremely slow,
we are gonna need a transposition table.
And I hope it wouldn't blow up exponentially that it couldn't even be used to compile std and testdir.
This would enforce a complete impossibility to rely on rules ordering (since all orderings would be tested) or schedule (since all values / blocks orderings would be tested)*.
*for the sample test code compiled under test mode.