|
@@ -1359,8 +1359,9 @@ static FCmpInst::Predicate evaluateFCmpRelation(Constant *V1, Constant *V2) {
|
|
assert(V1->getType() == V2->getType() &&
|
|
assert(V1->getType() == V2->getType() &&
|
|
"Cannot compare values of different types!");
|
|
"Cannot compare values of different types!");
|
|
|
|
|
|
- // Handle degenerate case quickly
|
|
|
|
- if (V1 == V2) return FCmpInst::FCMP_OEQ;
|
|
|
|
|
|
+ // We do not know if a constant expression will evaluate to a number or NaN.
|
|
|
|
+ // Therefore, we can only say that the relation is unordered or equal.
|
|
|
|
+ if (V1 == V2) return FCmpInst::FCMP_UEQ;
|
|
|
|
|
|
if (!isa<ConstantExpr>(V1)) {
|
|
if (!isa<ConstantExpr>(V1)) {
|
|
if (!isa<ConstantExpr>(V2)) {
|
|
if (!isa<ConstantExpr>(V2)) {
|
|
@@ -1855,7 +1856,6 @@ Constant *llvm::ConstantFoldCompareInstruction(unsigned short pred,
|
|
default: llvm_unreachable("Unknown relation!");
|
|
default: llvm_unreachable("Unknown relation!");
|
|
case FCmpInst::FCMP_UNO:
|
|
case FCmpInst::FCMP_UNO:
|
|
case FCmpInst::FCMP_ORD:
|
|
case FCmpInst::FCMP_ORD:
|
|
- case FCmpInst::FCMP_UEQ:
|
|
|
|
case FCmpInst::FCMP_UNE:
|
|
case FCmpInst::FCMP_UNE:
|
|
case FCmpInst::FCMP_ULT:
|
|
case FCmpInst::FCMP_ULT:
|
|
case FCmpInst::FCMP_UGT:
|
|
case FCmpInst::FCMP_UGT:
|
|
@@ -1901,6 +1901,13 @@ Constant *llvm::ConstantFoldCompareInstruction(unsigned short pred,
|
|
else if (pred == FCmpInst::FCMP_ONE || pred == FCmpInst::FCMP_UNE)
|
|
else if (pred == FCmpInst::FCMP_ONE || pred == FCmpInst::FCMP_UNE)
|
|
Result = 1;
|
|
Result = 1;
|
|
break;
|
|
break;
|
|
|
|
+ case FCmpInst::FCMP_UEQ: // We know that C1 == C2 || isUnordered(C1, C2).
|
|
|
|
+ // We can only partially decide this relation.
|
|
|
|
+ if (pred == FCmpInst::FCMP_ONE)
|
|
|
|
+ Result = 0;
|
|
|
|
+ else if (pred == FCmpInst::FCMP_UEQ)
|
|
|
|
+ Result = 1;
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
|
|
|
|
// If we evaluated the result, return it now.
|
|
// If we evaluated the result, return it now.
|