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