Fixes PR#40493, and in principle also PR#51551, but the known bits analysis isn't quite smart enough to handle the assume in the example there.
The entire logic for this patch has been discussed in PR#40493, it just seems that nobody has gotten around to implementing it yet.
https://alive2.llvm.org/ce/z/Bp6ZoV
https://alive2.llvm.org/ce/z/htSh_Q
(style) Don't use auto - APInt should be enough