It's first suggested by @craig.topper in D150068. I think there are at least three pros
- This can reduce the patterns during ISEL, as a result, reducing the bytes in X86GenDAGISel.inc
- The patterns for shift/rotate with immediate 1 look quite similar to shift/rotate with immediate 8. So this can be seen as eliminating "duplicate" code.
- Delay the optimization from imm8 to imm1, so that the previous optimization passes do not need to handle the version of imm1
It improves fast isel code and makes X86DomainReassignment work for shifts by 1, but regressed global isel, though no one should care.
Why not check the opcode first?