OSDN Git Service

Fix a source of undefined behavior when dealing with 64-bit types. This
authorChris Lattner <sabre@nondot.org>
Wed, 2 Nov 2005 01:47:04 +0000 (01:47 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 2 Nov 2005 01:47:04 +0000 (01:47 +0000)
may fix PR652.  Thanks to Andrew for tracking down the problem.

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

lib/CodeGen/SelectionDAG/DAGCombiner.cpp

index 048737f..b4bd5aa 100644 (file)
@@ -384,7 +384,7 @@ static bool MaskedValueIsZero(const SDOperand &Op, uint64_t Mask,
     return (Mask & ((1ULL << SrcBits)-1)) == 0; // Returning only the zext bits.
   case ISD::ZERO_EXTEND:
     SrcBits = MVT::getSizeInBits(Op.getOperand(0).getValueType());
-    return MaskedValueIsZero(Op.getOperand(0),Mask & ((1ULL << SrcBits)-1),TLI);
+    return MaskedValueIsZero(Op.getOperand(0),Mask & (~0ULL >> (64-SrcBits)),TLI);
   case ISD::AssertZext:
     SrcBits = MVT::getSizeInBits(cast<VTSDNode>(Op.getOperand(1))->getVT());
     return (Mask & ((1ULL << SrcBits)-1)) == 0; // Returning only the zext bits.