This patch fixes pr47668 (https://llvm.org/pr47668) by checking whether the shift amount is smaller than the bitwidth of variables.
This is done by checking whether Z is a constant and it is smaller than the bitwidth.
When the shift amount is undef, it is unsafe in theory because 1 << undef is poison, causing the miscompilation happen again.
To prevent this, I made the undef simply fold into zero, since shl 0 can be optimized later.
Proof to the first and second changes: https://alive2.llvm.org/ce/z/CVBwu9 , https://alive2.llvm.org/ce/z/h2ZWoW
The changes in f_var2* and f_var3* are checking whether src and tgt are identical, so proof not needed
clang-format not found in user's PATH; not linting file.