From e8945110d238289886cc51cafe9461bfcf109f6f Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 25 Apr 2022 13:18:31 +0200 Subject: [PATCH] [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 --- llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp index 4a97d6b..8c25d49 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); -- 2.7.4