[llvm] r367518 - [SelectionDAG] Use APInt::isSubsetOf/intersects to simplify some code.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 31 23:06:21 PDT 2019


Author: ctopper
Date: Wed Jul 31 23:06:21 2019
New Revision: 367518

URL: http://llvm.org/viewvc/llvm-project?rev=367518&view=rev
Log:
[SelectionDAG] Use APInt::isSubsetOf/intersects to simplify some code.

Also use KnownBits::isNegative/isNonNegative to further simplify.

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=367518&r1=367517&r2=367518&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Wed Jul 31 23:06:21 2019
@@ -3090,12 +3090,12 @@ KnownBits SelectionDAG::computeKnownBits
 
         // If the first operand is non-negative or has all low bits zero, then
         // the upper bits are all zero.
-        if (Known2.Zero[BitWidth-1] || ((Known2.Zero & LowBits) == LowBits))
+        if (Known2.isNonNegative() || LowBits.isSubsetOf(Known2.Zero))
           Known.Zero |= ~LowBits;
 
         // If the first operand is negative and not all low bits are zero, then
         // the upper bits are all one.
-        if (Known2.One[BitWidth-1] && ((Known2.One & LowBits) != 0))
+        if (Known2.isNegative() && LowBits.intersects(Known2.One))
           Known.One |= ~LowBits;
         assert((Known.Zero & Known.One) == 0&&"Bits known to be one AND zero?");
       }




More information about the llvm-commits mailing list