mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-26 23:29:22 +00:00
Fix ICmpInst::makeConstantRange to use ConstantRange's API properly
in the case of empty and full ranges. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94548 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8dcc58e6b4
commit
f21107c07a
@ -2865,25 +2865,53 @@ ICmpInst::makeConstantRange(Predicate pred, const APInt &C) {
|
|||||||
default: llvm_unreachable("Invalid ICmp opcode to ConstantRange ctor!");
|
default: llvm_unreachable("Invalid ICmp opcode to ConstantRange ctor!");
|
||||||
case ICmpInst::ICMP_EQ: Upper++; break;
|
case ICmpInst::ICMP_EQ: Upper++; break;
|
||||||
case ICmpInst::ICMP_NE: Lower++; break;
|
case ICmpInst::ICMP_NE: Lower++; break;
|
||||||
case ICmpInst::ICMP_ULT: Lower = APInt::getMinValue(BitWidth); break;
|
case ICmpInst::ICMP_ULT:
|
||||||
case ICmpInst::ICMP_SLT: Lower = APInt::getSignedMinValue(BitWidth); break;
|
Lower = APInt::getMinValue(BitWidth);
|
||||||
|
// Check for an empty-set condition.
|
||||||
|
if (Lower == Upper)
|
||||||
|
return ConstantRange(BitWidth, /*isFullSet=*/false);
|
||||||
|
break;
|
||||||
|
case ICmpInst::ICMP_SLT:
|
||||||
|
Lower = APInt::getSignedMinValue(BitWidth);
|
||||||
|
// Check for an empty-set condition.
|
||||||
|
if (Lower == Upper)
|
||||||
|
return ConstantRange(BitWidth, /*isFullSet=*/false);
|
||||||
|
break;
|
||||||
case ICmpInst::ICMP_UGT:
|
case ICmpInst::ICMP_UGT:
|
||||||
Lower++; Upper = APInt::getMinValue(BitWidth); // Min = Next(Max)
|
Lower++; Upper = APInt::getMinValue(BitWidth); // Min = Next(Max)
|
||||||
|
// Check for an empty-set condition.
|
||||||
|
if (Lower == Upper)
|
||||||
|
return ConstantRange(BitWidth, /*isFullSet=*/false);
|
||||||
break;
|
break;
|
||||||
case ICmpInst::ICMP_SGT:
|
case ICmpInst::ICMP_SGT:
|
||||||
Lower++; Upper = APInt::getSignedMinValue(BitWidth); // Min = Next(Max)
|
Lower++; Upper = APInt::getSignedMinValue(BitWidth); // Min = Next(Max)
|
||||||
|
// Check for an empty-set condition.
|
||||||
|
if (Lower == Upper)
|
||||||
|
return ConstantRange(BitWidth, /*isFullSet=*/false);
|
||||||
break;
|
break;
|
||||||
case ICmpInst::ICMP_ULE:
|
case ICmpInst::ICMP_ULE:
|
||||||
Lower = APInt::getMinValue(BitWidth); Upper++;
|
Lower = APInt::getMinValue(BitWidth); Upper++;
|
||||||
|
// Check for a full-set condition.
|
||||||
|
if (Lower == Upper)
|
||||||
|
return ConstantRange(BitWidth, /*isFullSet=*/true);
|
||||||
break;
|
break;
|
||||||
case ICmpInst::ICMP_SLE:
|
case ICmpInst::ICMP_SLE:
|
||||||
Lower = APInt::getSignedMinValue(BitWidth); Upper++;
|
Lower = APInt::getSignedMinValue(BitWidth); Upper++;
|
||||||
|
// Check for a full-set condition.
|
||||||
|
if (Lower == Upper)
|
||||||
|
return ConstantRange(BitWidth, /*isFullSet=*/true);
|
||||||
break;
|
break;
|
||||||
case ICmpInst::ICMP_UGE:
|
case ICmpInst::ICMP_UGE:
|
||||||
Upper = APInt::getMinValue(BitWidth); // Min = Next(Max)
|
Upper = APInt::getMinValue(BitWidth); // Min = Next(Max)
|
||||||
|
// Check for a full-set condition.
|
||||||
|
if (Lower == Upper)
|
||||||
|
return ConstantRange(BitWidth, /*isFullSet=*/true);
|
||||||
break;
|
break;
|
||||||
case ICmpInst::ICMP_SGE:
|
case ICmpInst::ICMP_SGE:
|
||||||
Upper = APInt::getSignedMinValue(BitWidth); // Min = Next(Max)
|
Upper = APInt::getSignedMinValue(BitWidth); // Min = Next(Max)
|
||||||
|
// Check for a full-set condition.
|
||||||
|
if (Lower == Upper)
|
||||||
|
return ConstantRange(BitWidth, /*isFullSet=*/true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return ConstantRange(Lower, Upper);
|
return ConstantRange(Lower, Upper);
|
||||||
|
Loading…
Reference in New Issue
Block a user