Description
The LLVM docs for shl
say
If op2 is (statically or dynamically) equal to or larger than the number of bits in op1, this instruction returns a poison value.
However, the CTFE/Miri implementation of shl/shr currently just truncates the shift amount. In rustc-generated MIR this can never happen since there always is a check being emitted, but we should still make sure to implement all UB checks for this operation correctly -- and the simd_shl
intrinsic also exposes direct access to this operation, making it possible to trigger this UB. (I plan to add tests for this.)
I just hope we didn't miss any other MIR operations which compile ti LLVM arithmetic operations that can produce poison/undef/UB... (we do check for div-by-zero, of course). Cc @rust-lang/wg-llvm