avoid useless icmp-ne insertion in visitor

This commit is contained in:
ridethepig 2023-05-21 10:34:23 +08:00
parent b5e1610047
commit 5e6107a02e

View File

@ -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;
}