[llvm] b83aa8b - [DAG] computeOverflowForUnsignedAdd - use getMaxValue().ult(2) to detect 0/1 values. NFCI.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Sat May 6 11:46:46 PDT 2023
Author: Simon Pilgrim
Date: 2023-05-06T19:46:34+01:00
New Revision: b83aa8bc75789c0df988dedb9474aaee84ef4bb4
URL: https://github.com/llvm/llvm-project/commit/b83aa8bc75789c0df988dedb9474aaee84ef4bb4
DIFF: https://github.com/llvm/llvm-project/commit/b83aa8bc75789c0df988dedb9474aaee84ef4bb4.diff
LOG: [DAG] computeOverflowForUnsignedAdd - use getMaxValue().ult(2) to detect 0/1 values. NFCI.
Added:
Modified:
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index a78b7971d327..942d2641ba7d 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -3976,15 +3976,11 @@ SelectionDAG::computeOverflowForUnsignedAdd(SDValue N0, SDValue N1) const {
// mulhi + 1 never overflow
if (N0.getOpcode() == ISD::UMUL_LOHI && N0.getResNo() == 1 &&
- (N1Known.getMaxValue() & 0x01) == N1Known.getMaxValue())
+ N1Known.getMaxValue().ult(2))
+ return OFK_Never;
+ if (N1.getOpcode() == ISD::UMUL_LOHI && N1.getResNo() == 1 &&
+ computeKnownBits(N0).getMaxValue().ult(2))
return OFK_Never;
-
- if (N1.getOpcode() == ISD::UMUL_LOHI && N1.getResNo() == 1) {
- KnownBits N0Known = computeKnownBits(N0);
-
- if ((N0Known.getMaxValue() & 0x01) == N0Known.getMaxValue())
- return OFK_Never;
- }
// TODO: Add ConstantRange::unsignedAddMayOverflow handling.
return OFK_Sometime;
More information about the llvm-commits
mailing list