In D68103 the InstCombine learned that shift-by-sext is simply a shift-by-zext.
But the transform is limited to single-use sext.
That is too limiting. We should handle cases with extra uses.
Here it is proposed to just always do the transformation,
on the basis that zext is unarguably better for any further analysis.
There are other alternatives
- Simply ensure that all uses of this sext are shifts - O(N^2) in case if there are non-shift uses
- Add more greedy version of the fold into AggressiveInstCombine - checking that all uses can be converted to zext - could be as simple as again simply checking that they are all shifts. Will not have O(N^2) problem, but will have usability problem - AggressiveInstCombine only runs in -O3, not even in -O2?
So i suspect this might be the least of the evils..