Closed RKSimon closed 1 year ago
The add/sub saturated instruction are now generic opcodes, InstCombine already does this pretty thoroughly but we need to add at least basic support in DAGCombine as we can create these nodes there as well.
ISD::UADDSAT was added at rL351026 (with a bugfix for ISD::SADDAT at rL351057).
Resolving - visitADDSAT/visitSUBSAT use the willNotOverflowAdd/willNotOverflowSub helpers to relax to regular ADD/SUB - 56ba1db933ea / 3fb067f7ba8e / 8f82d8ee7603
X86 doesn't do anything with the HADDS/HSUBS instructions, so that can be left as a future x86-specific issue if a need arises.
Extended Description
If the saturated nodes are guaranteed not to overflow then they should become generic ADD/SUB nodes. As a stretch goal the HADDS/HSUBS cases could be handled as well.
Many CPUs can perform the saturated forms only on some ports, or at a lower perf.