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

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 18 00:33:31 PST 2021


lebedev.ri added a comment.

I'm somewhat unconvinced that we can solve this problem at the match stage.
Consider

  v0 = a + c
  v1 = v0 + c
  v2 = v1 + c
  r = v2 + c

if you do `match(m_Add(m_Add(m_Add(m_Add(m_Value(A), m_Value(C)), m_Specific(C)), m_Specific(C)), m_Specific(C)))`,
i think `UseComplexity` will be 4(?), but that doesn't mean that you can create 4 instructions,
in reality it depends on the pattern you will produce. If you want to produce a + 4*c, sure, you can do that,
because none of the instructions you matched are used in the pattern. But if you want to produce
`v2 + 1*c`, you can not, because that would increase instruction count...


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

https://reviews.llvm.org/D114126



More information about the llvm-commits mailing list