Skip to content

Commit b0210a9

Browse files
committed
fix lowering of LLVM's 'fcmp true/false'
https://reviews.llvm.org/D121243
1 parent 412aa96 commit b0210a9

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

ir/instr.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2262,6 +2262,8 @@ void FCmp::print(ostream &os) const {
22622262
case ULE: condtxt = "ule "; break;
22632263
case UNE: condtxt = "une "; break;
22642264
case UNO: condtxt = "uno "; break;
2265+
case TRUE: condtxt = "true "; break;
2266+
case FALSE: condtxt = "false "; break;
22652267
}
22662268
os << getName() << " = fcmp " << fmath << condtxt << *a << ", "
22672269
<< b->getName();
@@ -2288,6 +2290,8 @@ StateValue FCmp::toSMT(State &s) const {
22882290
case ULE: return a.fule(b);
22892291
case UNE: return a.fune(b);
22902292
case UNO: return a.funo(b);
2293+
case TRUE: return expr(true);
2294+
case FALSE: return expr(false);
22912295
}
22922296
UNREACHABLE();
22932297
};

ir/instr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ class ICmp final : public Instr {
358358
class FCmp final : public Instr {
359359
public:
360360
enum Cond { OEQ, OGT, OGE, OLT, OLE, ONE, ORD,
361-
UEQ, UGT, UGE, ULT, ULE, UNE, UNO };
361+
UEQ, UGT, UGE, ULT, ULE, UNE, UNO, TRUE, FALSE };
362362

363363
private:
364364
Value *a, *b;

llvm_util/llvm2alive.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -444,16 +444,8 @@ class llvm2alive_ : public llvm::InstVisitor<llvm2alive_, unique_ptr<Instr>> {
444444
case llvm::CmpInst::FCMP_ULE: cond = FCmp::ULE; break;
445445
case llvm::CmpInst::FCMP_UNE: cond = FCmp::UNE; break;
446446
case llvm::CmpInst::FCMP_UNO: cond = FCmp::UNO; break;
447-
case llvm::CmpInst::FCMP_TRUE: {
448-
auto tru = get_operand(llvm::ConstantInt::getTrue(i.getType()));
449-
RETURN_IDENTIFIER(make_unique<UnaryOp>(*ty, value_name(i), *tru,
450-
UnaryOp::Copy));
451-
}
452-
case llvm::CmpInst::FCMP_FALSE: {
453-
auto fals = get_operand(llvm::ConstantInt::getFalse(i.getType()));
454-
RETURN_IDENTIFIER(make_unique<UnaryOp>(*ty, value_name(i), *fals,
455-
UnaryOp::Copy));
456-
}
447+
case llvm::CmpInst::FCMP_TRUE: cond = FCmp::TRUE; break;
448+
case llvm::CmpInst::FCMP_FALSE: cond = FCmp::FALSE; break;
457449
default:
458450
UNREACHABLE();
459451
}

0 commit comments

Comments
 (0)