The following simplifications are implemented:
- fshl(X, 0, C) -> shl X, C%BW
- fshl(X, undef, C) -> shl X, C%BW (assuming undef = 0)
- fshl(0, X, C) -> lshr X, BW-C%BW
- fshl(undef, X, C) -> lshr X, BW-C%BW (assuming undef = 0)
- fshr(X, 0, C) -> shl X, (BW-C%BW)
- fshr(X, undef, C) -> shl X, BW-C%BW (assuming undef = 0)
- fshr(0, X, C) -> lshr X, C%BW
- fshr(undef, X, C) -> lshr, X, C%BW (assuming undef = 0)
The simplification is only performed if the shift amount C is constant, because we can explicitly compute C%BW and BW-C%BW in this case.
This change has been split off from D54666 and handling for the zero case has been added. Unfortunately that also means new tests :(
This can be made an assert. We are guaranteed to call InstSimplify (line 1844) for this instruction before we reach this point in InstCombine.