diff --git a/src/visitor.cpp b/src/visitor.cpp index 45d4218..6c3e9cd 100644 --- a/src/visitor.cpp +++ b/src/visitor.cpp @@ -533,7 +533,9 @@ std::any Visitor::visitLAndExp(SysyParser::LAndExpContext *ctx) { for (int i = 0; i < eq_exp_list.size(); ++i) { auto next_block = build_BasicBlock("", _state.current_func, _state.current_bb->itr); auto eq_exp = any_to_Value(visitEqExp(eq_exp_list[i])); - auto condition = build_InstBinary(InstTag::Ne, eq_exp, CONST0, _state.current_bb); + auto condition = eq_exp; + if (!TypeHelper::isIntegerTypeI1(eq_exp->type)) + condition = build_InstBinary(InstTag::Ne, eq_exp, CONST0, _state.current_bb); build_InstBranch(condition, next_block, ctx->false_block, _state.current_bb); _state.current_bb = next_block; }