On 10/08/2015 08:03 PM, Joseph Myers wrote:
On Thu, 8 Oct 2015, Bernd Schmidt wrote:
On 10/07/2015 11:54 AM, Hurugalawadi, Naveen wrote:
Move Fold X & (X ^ Y) as X & ~Y to match.pd.
Move Fold X & (Y ^ X) as ~Y & X to match.pd.
I wonder if we shouldn't try to autogenerate patterns such as these. I did
something like that for a different project a long time ago. Generate
expressions up to a certain level of complexity, identify which ones are
equivalent, and pick the one with the lowest cost for simplifications...
Any bitwise expression whose ultimate operands are X, Y, 0 and -1
(possibly with conversions among types of the same width) could be
canonicalized to one of: 0, -1, X, Y, ~X, ~Y, X^Y, X^~Y, A&B or A|B (where
A is X or ~X and B is Y or ~Y). I don't guarantee those are the best
canonical forms, but if you're folding this sort of expression you ought
to be able to make GCC fold all such expressions down to some such form
(and fold away all equality comparisons among such expressions with
constant value).
I was actually thinking of also doing this for more complex expressions
with more than two different operands.
Bernd