From ad19a6715f88914eb18e1b8a5b3f1521516794a5 Mon Sep 17 00:00:00 2001 From: rain2133 <1370973498@qq.com> Date: Sun, 10 Aug 2025 16:57:40 +0800 Subject: [PATCH] =?UTF-8?q?[midend]=E5=88=A0=E9=99=A4=E4=BA=86=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84sra=E6=8C=87=E4=BB=A4=E7=94=9F=E6=88=90?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/midend/SysYIRGenerator.cpp | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/src/midend/SysYIRGenerator.cpp b/src/midend/SysYIRGenerator.cpp index 7ff316a..541c976 100644 --- a/src/midend/SysYIRGenerator.cpp +++ b/src/midend/SysYIRGenerator.cpp @@ -389,26 +389,7 @@ void SysYIRGenerator::compute() { case BinaryOp::ADD: resultValue = builder.createAddInst(lhs, rhs); break; case BinaryOp::SUB: resultValue = builder.createSubInst(lhs, rhs); break; case BinaryOp::MUL: resultValue = builder.createMulInst(lhs, rhs); break; - case BinaryOp::DIV: { - ConstantInteger *rhsConst = dynamic_cast(rhs); - if (rhsConst) { - int divisor = rhsConst->getInt(); - if (divisor > 0 && (divisor & (divisor - 1)) == 0) { - int shift = 0; - int temp = divisor; - while (temp > 1) { - temp >>= 1; - shift++; - } - resultValue = builder.createSRAInst(lhs, ConstantInteger::get(shift)); - } else { - resultValue = builder.createDivInst(lhs, rhs); - } - } else { - resultValue = builder.createDivInst(lhs, rhs); - } - break; - } + case BinaryOp::DIV: resultValue = builder.createDivInst(lhs, rhs); break; case BinaryOp::MOD: resultValue = builder.createRemInst(lhs, rhs); break; } } else if (commonType == Type::getFloatType()) {