[llvm-commits] [llvm] r126637 - /llvm/trunk/lib/Analysis/ValueTracking.cpp

Nick Lewycky nicholas at mxc.ca
Sun Feb 27 22:52:12 PST 2011


Author: nicholas
Date: Mon Feb 28 00:52:12 2011
New Revision: 126637

URL: http://llvm.org/viewvc/llvm-project?rev=126637&view=rev
Log:
Teach ValueTracking to look at the dividend when determining the sign bit of an
srem instruction.

Modified:
    llvm/trunk/lib/Analysis/ValueTracking.cpp

Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=126637&r1=126636&r2=126637&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp Mon Feb 28 00:52:12 2011
@@ -460,6 +460,18 @@
         assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); 
       }
     }
+    if (Mask.isNegative()) {  // We're looking for the sign bit.
+      APInt Mask2 = APInt::getSignBit(BitWidth);
+      KnownZero2 = 0;
+      KnownOne2 = 0;
+      ComputeMaskedBits(I->getOperand(0), Mask2, KnownZero2, KnownOne2, TD, 
+                        Depth+1);
+      if (KnownOne2[BitWidth-1])
+        KnownOne |= Mask2;
+      if (KnownZero2[BitWidth-1])
+        KnownZero |= Mask2;
+      assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?");
+    }
     break;
   case Instruction::URem: {
     if (ConstantInt *Rem = dyn_cast<ConstantInt>(I->getOperand(1))) {





More information about the llvm-commits mailing list