[PATCH] D114126: [PatternMatch] Create match method to track uses complexity

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 7 06:33:38 PST 2022


spatel added a comment.

I'm not opposed to the direction, but I don't have enough C++ knowledge to review the implementation.

@nikic commented on the exactness of use counting that we've created and wondered if we need to try so hard. I sympathize/agree with that view.
But I've actually hoped that we could loosen the constraints on some patterns - that is, allow the creation of more instructions because the transform is still beneficial from an overall use count.
Take for example one of the motivating Demorgan patterns for this patch:
https://alive2.llvm.org/ce/z/4XGCm3
The 'not' ops have extra uses, so we don't do: (~A & ~B) --> ~(A | B) even though that would get the final result in 2 ops instead of 3. But we don't do the inverse transform either (it requires more than simple pattern-matching). 
If we removed some strictness about uses, we probably wouldn't require this patch or the follow-ons for complicated bitwise logic optimizations. Those are only needed because we miss the simpler, intermediate folds in complex expressions with extra uses. I suppose we'd be more at risk for infinite combine loops if we allowed creating extra instructions, but it might be worth experimenting with removing some use checks on bitwise logic folds to see how that plays out.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114126/new/

https://reviews.llvm.org/D114126



More information about the llvm-commits mailing list