[llvm] r285822 - Use !operator to test if APInt is zero/non-zero. NFCI.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 2 08:41:15 PDT 2016


Author: rksimon
Date: Wed Nov  2 10:41:15 2016
New Revision: 285822

URL: http://llvm.org/viewvc/llvm-project?rev=285822&view=rev
Log:
Use !operator to test if APInt is zero/non-zero. NFCI.

Avoids APInt construction and slower comparisons.

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=285822&r1=285821&r2=285822&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Wed Nov  2 10:41:15 2016
@@ -2036,7 +2036,7 @@ void SelectionDAG::computeKnownBits(SDVa
   APInt KnownZero2, KnownOne2;
   unsigned NumElts = DemandedElts.getBitWidth();
 
-  if (DemandedElts == APInt(NumElts, 0))
+  if (!DemandedElts)
     return;  // No demanded elts, better to assume we don't know anything.
 
   switch (Op.getOpcode()) {
@@ -2099,13 +2099,13 @@ void SelectionDAG::computeKnownBits(SDVa
         DemandedRHS.setBit((unsigned)M % NumElts);
     }
     // Known bits are the values that are shared by every demanded element.
-    if (DemandedLHS != APInt(NumElts, 0)) {
+    if (!!DemandedLHS) {
       SDValue LHS = Op.getOperand(0);
       computeKnownBits(LHS, KnownZero2, KnownOne2, DemandedLHS, Depth + 1);
       KnownOne &= KnownOne2;
       KnownZero &= KnownZero2;
     }
-    if (DemandedRHS != APInt(NumElts, 0)) {
+    if (!!DemandedRHS) {
       SDValue RHS = Op.getOperand(1);
       computeKnownBits(RHS, KnownZero2, KnownOne2, DemandedRHS, Depth + 1);
       KnownOne &= KnownOne2;




More information about the llvm-commits mailing list