I’m looking into problems with the function DAGCombiner::MatchBSwapHWord and had a couple questions on how to proceed (I’m new here, and to llvm). It looks like there was never any test coverage for this code, and it doesn’t match the patterns it claims to be looking for. I found a fix for this in our fork, but the fix is even worse in that it matches a whole bunch of invalid patterns as well as the canonical patterns. I have simple test cases that break both the existing code and our local fix.
I see equivalent matching code upstream in InstCombiner::MatchBSwap() (InstCombineAndOrXor.cpp), but not an easy way to re-use it AFAICT. Questions:
–Is this functionality even worth fixing in DAGCombiner (ie, what is the probability that this complex pattern would re-emerge in codegen after the InstCombiner transform, weighed against the obviously error-prone nature of the matching code)?
–If so, I can patch up and test the existing logic, but since the original code is quite old I wanted to reach out for any modernization advice before embarking on that effort.