Index: llvm/lib/IR/ConstantRange.cpp =================================================================== --- llvm/lib/IR/ConstantRange.cpp +++ llvm/lib/IR/ConstantRange.cpp @@ -1478,8 +1478,10 @@ APInt OtherMax = Other.getUnsignedMax(); + bool Neg = getSingleElement() && isAllNegative(); + // There's overflow! - if (OtherMax.ugt(Max.countl_zero())) + if (OtherMax.ugt(Max.countl_zero()) && !Neg) return getFull(); // FIXME: implement the other tricky cases @@ -1487,6 +1489,10 @@ Min <<= Other.getUnsignedMin(); Max <<= OtherMax; + // For negitive value c, its shifted range is [c<