[llvm] c557d31 - [InstCombine] Use computeKnownBits() for srem SimplifyDemandedBits()

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed May 17 06:57:31 PDT 2023


Author: Nikita Popov
Date: 2023-05-17T15:57:23+02:00
New Revision: c557d3109a942bc4fb93b690ceb70de8a3d53d30

URL: https://github.com/llvm/llvm-project/commit/c557d3109a942bc4fb93b690ceb70de8a3d53d30
DIFF: https://github.com/llvm/llvm-project/commit/c557d3109a942bc4fb93b690ceb70de8a3d53d30.diff

LOG: [InstCombine] Use computeKnownBits() for srem SimplifyDemandedBits()

For the case of a non-constant operand, fall back to
computeKnownBits() rather than trying to reimplement logic.

Found while testing a consistency assertion for both functions.

Added: 
    

Modified: 
    llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index 231739d903b3..c9c7f4a53cc8 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -852,14 +852,7 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
       }
     }
 
-    // The sign bit is the LHS's sign bit, except when the result of the
-    // remainder is zero.
-    if (DemandedMask.isSignBitSet()) {
-      computeKnownBits(I->getOperand(0), LHSKnown, Depth + 1, CxtI);
-      // If it's known zero, our sign bit is also zero.
-      if (LHSKnown.isNonNegative())
-        Known.makeNonNegative();
-    }
+    computeKnownBits(I, Known, Depth, CxtI);
     break;
   }
   case Instruction::URem: {


        


More information about the llvm-commits mailing list