[llvm] Add more cases for computeOverflowForSignedAdd (PR #99900)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 23 02:41:26 PDT 2024


================
@@ -4242,8 +4242,19 @@ SelectionDAG::computeOverflowForSignedAdd(SDValue N0, SDValue N1) const {
   if (ComputeNumSignBits(N0) > 1 && ComputeNumSignBits(N1) > 1)
     return OFK_Never;
 
-  // TODO: Add ConstantRange::signedAddMayOverflow handling.
-  return OFK_Sometime;
+  // smulhi + any value never overflow
----------------
jayfoad wrote:

This is clearly nonsense. smulhi plus _some_ values can overflow. The useful thing you know about smulhi is that it is in a restricted range, e.g. (for 32 bits) -0x40000000 to +0x3fffffff.

https://github.com/llvm/llvm-project/pull/99900


More information about the llvm-commits mailing list