From 5e6107a02eac97d615350957571d6e4d89b2222b Mon Sep 17 00:00:00 2001 From: ridethepig Date: Sun, 21 May 2023 10:34:23 +0800 Subject: [PATCH] avoid useless icmp-ne insertion in visitor --- src/visitor.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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; }