llvm.org GIT mirror llvm / d3b64ef
make ConstantRange::signExtend() optimal the case [x, INT_MIN) was not handled optimally git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193694 91177308-0d34-0410-b5e6-96231b3b80d8 Nuno Lopes 5 years ago
2 changed file(s) with 8 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
444444
445445 unsigned SrcTySize = getBitWidth();
446446 assert(SrcTySize < DstTySize && "Not a value extension");
447
448 // special case: [X, INT_MIN) -- not really wrapping around
449 if (Upper == APInt::getHighBitsSet(SrcTySize, 1))
450 return ConstantRange(Lower.sext(DstTySize), Upper.zext(DstTySize));
451
447452 if (isFullSet() || isSignWrappedSet()) {
448453 return ConstantRange(APInt::getHighBitsSet(DstTySize,DstTySize-SrcTySize+1),
449454 APInt::getLowBitsSet(DstTySize, SrcTySize-1) + 1);
215215
216216 EXPECT_EQ(ConstantRange(APInt(8, 120), APInt(8, 140)).signExtend(16),
217217 ConstantRange(APInt(16, -128), APInt(16, 128)));
218
219 EXPECT_EQ(ConstantRange(APInt(16, 0x0200), APInt(16, 0x8000)).signExtend(19),
220 ConstantRange(APInt(19, 0x0200), APInt(19, 0x8000)));
218221 }
219222
220223 TEST_F(ConstantRangeTest, IntersectWith) {