Description
Feature
If ISLE sees a pattern like (rule (simplify foo (bar x) (bar x)))
, after checking the first (bar x)
condition it should check whether the second argument to foo
is equal to the first argument. If so, then we know (bar x)
will match on the second argument as well, and don't need to check it again. If the arguments are not equal, we should go ahead and check the subpattern like we do today.
Benefit
These kinds of patterns show up in mid-end optimization rules. During those rules we've already done GVN, so if the pattern matches both values, then the values will be the same. As a result, this proposed optimization should fire a lot.
Implementation
I haven't thought that hard about this yet.
This partially undoes a transformation that trie_again
does, except that we have to fall back to checking each subpattern in some cases. Looking at that transformation might provide some inspiration.