[llvm] [Mips] Do not emit instruction teq if divisor is non-zero immediate value in FastISel implementation (PR #135768)
YunQiang Su via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 23 02:33:22 PDT 2025
================
@@ -1947,7 +1947,12 @@ bool MipsFastISel::selectDivRem(const Instruction *I, unsigned ISDOpcode) {
return false;
emitInst(DivOpc).addReg(Src0Reg).addReg(Src1Reg);
- emitInst(Mips::TEQ).addReg(Src1Reg).addReg(Mips::ZERO).addImm(7);
+ if (const ConstantInt *C = dyn_cast<ConstantInt>(I->getOperand(1))) {
----------------
wzssyqa wrote:
Soooo cooool.
While we can have a better code style.
Something like
```
if (!isa<ConstantInt>(I->getOperand(1)) || I->getConstantOperandVal(1) == 0)
...
else
...
```
https://github.com/llvm/llvm-project/pull/135768
More information about the llvm-commits
mailing list