https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125405
--- Comment #2 from Jeffrey A. Law <law at gcc dot gnu.org> --- match.pd isn't my area of expertise, but the patterns seem roughly sensible. Rather than using magic numbers like 127/128 32767/32768 there should be information in the tree type we can derive those from. We'll have to do something with the output types too. That's too much hardcoding. We also have to be careful with bitint stuff. Essentially you can have types that aren't 2^n bits wide. There's a predicate that you can test to verify the underlying type is sensible for this, I just can't remember it's name offhand.
