HomePhabricator

[DAGCombiner] Optimize SMULO/UMULO if we can prove that overflow is impossible.

Authored by craig.topper on Feb 26 2021, 2:50 PM.

Description

[DAGCombiner] Optimize SMULO/UMULO if we can prove that overflow is impossible.

Using ComputeNumSignBits or computeKnownBits we might be able
to determine that overflow is impossible.

This especially helps after type legalization if the type was
promoted from a type with half the bits or more. Type legalization
conservatively creates a promoted smulo/umulo and an overflow
check for the promoted bits. The overflow from the promoted
smulo/umulo is ORed with the result of the promoted bits
overflow check. Proving that the promoted smulo/umulo can never
overflow will leave us with just the promoted bits overflow check.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D97160