If we have enough signbits in a source value, we can skip an intermediate cast for a trunc+sext pair:
https://alive2.llvm.org/ce/z/A_mQt-
This is the original problem shown in:
https://llvm.org/PR49543
There's a test that shows we transformed what used to be a pair of shifts, so that suggests we could add another ComputeNumSignBits fold starting from a shift.
There does not appear to be any change in compile-time from the extra analysis:
https://llvm-compile-time-tracker.com/compare.php?from=3d2c9069dcafd0cbb641841aa3dd6e851fb7d760&to=b9513cdf2419704c7bb0c3a02a9ca06aae13d902&stat=instructions