When tracking demanded bits, if any bits from the sext of an SRA are demanded,
authorChris Lattner <sabre@nondot.org>
Mon, 8 May 2006 17:22:53 +0000 (17:22 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 8 May 2006 17:22:53 +0000 (17:22 +0000)
then so is the input sign bit.  This fixes mediabench/g721 on X86.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28166 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/TargetLowering.cpp

index 41405408de53144e23e8af4e9a6588f01d9ba021..bbe8e95b785966d88dedb67f48218384fed8164b 100644 (file)
@@ -467,8 +467,14 @@ bool TargetLowering::SimplifyDemandedBits(SDOperand Op, uint64_t DemandedMask,
       HighBits <<= MVT::getSizeInBits(VT) - ShAmt;
       uint64_t TypeMask = MVT::getIntVTBitMask(VT);
       
-      if (SimplifyDemandedBits(Op.getOperand(0),
-                               (DemandedMask << ShAmt) & TypeMask,
+      uint64_t InDemandedMask = (DemandedMask << ShAmt) & TypeMask;
+
+      // If any of the demanded bits are produced by the sign extension, we also
+      // demand the input sign bit.
+      if (HighBits & DemandedMask)
+        InDemandedMask |= MVT::getIntVTSignBit(VT);
+      
+      if (SimplifyDemandedBits(Op.getOperand(0), InDemandedMask,
                                KnownZero, KnownOne, TLO, Depth+1))
         return true;
       assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?");