As of rL125457, the shift amount operand is always zero-extended when being promoted. This is conservatively safe, but on some targets (e.g. RISC-V) this leads to unnecessary instructions as the native shift operations ignore all but the lower 5/6 bits.
This patch introduces the getExtendForShiftAmount hook which is called from SelectionDAGBuilder::visitShift and implements that hook for RISC-V. The benefit can be seen in the promoted 8 and 16-bit shifts in the test/CodeGen/RISCV/alu{8,16}.ll test cases.