Index: llvm/lib/IR/ConstantRange.cpp =================================================================== --- llvm/lib/IR/ConstantRange.cpp +++ llvm/lib/IR/ConstantRange.cpp @@ -1478,8 +1478,11 @@ APInt OtherMax = Other.getUnsignedMax(); + bool Neg = getSingleElement() && isAllNegative() && + OtherMax.ule(Max.abs().countl_zero()); + // 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 +1490,10 @@ Min <<= Other.getUnsignedMin(); Max <<= OtherMax; + // For negitive value c, its shifted range is [c<