[llvm] e894511 - [InstCombine] Remove redundant unsigned underflow fold (NFCI)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 25 05:22:50 PDT 2022
Author: Nikita Popov
Date: 2022-04-25T14:22:43+02:00
New Revision: e8945110d238289886cc51cafe9461bfcf109f6f
URL: https://github.com/llvm/llvm-project/commit/e8945110d238289886cc51cafe9461bfcf109f6f
DIFF: https://github.com/llvm/llvm-project/commit/e8945110d238289886cc51cafe9461bfcf109f6f.diff
LOG: [InstCombine] Remove redundant unsigned underflow fold (NFCI)
This is now handled as a combination of two other folds:
(A+B) <= A & (A+B) != 0 --> (A+B)-1 < A
(A+B)-1 < A --> -B < A
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index 4a97d6b83767b..8c25d4992f736 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -991,22 +991,13 @@ static Value *foldUnsignedUnderflowCheck(ICmpInst *ZeroICmp,
};
// Given ZeroCmpOp = (A + B)
- // ZeroCmpOp <= A && ZeroCmpOp != 0 --> (0-B) < A
- // ZeroCmpOp > A || ZeroCmpOp == 0 --> (0-B) >= A
- //
// ZeroCmpOp < A && ZeroCmpOp != 0 --> (0-X) < Y iff
// ZeroCmpOp >= A || ZeroCmpOp == 0 --> (0-X) >= Y iff
// with X being the value (A/B) that is known to be non-zero,
// and Y being remaining value.
- if (UnsignedPred == ICmpInst::ICMP_ULE && EqPred == ICmpInst::ICMP_NE &&
- IsAnd)
- return Builder.CreateICmpULT(Builder.CreateNeg(B), A);
if (UnsignedPred == ICmpInst::ICMP_ULT && EqPred == ICmpInst::ICMP_NE &&
IsAnd && GetKnownNonZeroAndOther(B, A))
return Builder.CreateICmpULT(Builder.CreateNeg(B), A);
- if (UnsignedPred == ICmpInst::ICMP_UGT && EqPred == ICmpInst::ICMP_EQ &&
- !IsAnd)
- return Builder.CreateICmpUGE(Builder.CreateNeg(B), A);
if (UnsignedPred == ICmpInst::ICMP_UGE && EqPred == ICmpInst::ICMP_EQ &&
!IsAnd && GetKnownNonZeroAndOther(B, A))
return Builder.CreateICmpUGE(Builder.CreateNeg(B), A);
More information about the llvm-commits
mailing list