[llvm] b13d5df - [DAG] ComputeKnownBits - use KnownBits::usub_sat instead of a custom variant

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 28 05:07:04 PST 2024


Author: Simon Pilgrim
Date: 2024-01-28T13:06:57Z
New Revision: b13d5df84c2f3888e6775ce207b21e17bbf5cd1d

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

LOG: [DAG] ComputeKnownBits - use KnownBits::usub_sat instead of a custom variant

KnownBits::usub_sat is already exhaustively tested in the unit tests

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 3691a7f3c4aee6e..a3d8d253437ca89 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -3903,9 +3903,9 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, const APInt &DemandedElts,
     break;
   }
   case ISD::USUBSAT: {
-    // The result of usubsat will never be larger than the LHS.
-    Known2 = computeKnownBits(Op.getOperand(0), DemandedElts, Depth + 1);
-    Known.Zero.setHighBits(Known2.countMinLeadingZeros());
+    Known = computeKnownBits(Op.getOperand(0), DemandedElts, Depth + 1);
+    Known2 = computeKnownBits(Op.getOperand(1), DemandedElts, Depth + 1);
+    Known = KnownBits::usub_sat(Known, Known2);
     break;
   }
   case ISD::UMIN: {


        


More information about the llvm-commits mailing list