Pulled from D87452, this is a fixed version of the collectBitParts fshl/fshr handling which as @nikic noticed wasn't checking for different providers or had correct bit ordering (which was hid by only testing shift amounts of bitwidth/2).
This LGTM now, thanks!
I would if (auto *II = dyn_cast<IntrinsicInst>(I)) and then II->getInrinsicID() here. Doesn't seem necessary to explicitly go through the Function.
modulo -> modulo the bitwidth?