[Mips] Do not emit teq if NoZeroDivCheck in FastISel - #204386
Conversation
|
@llvm/pr-subscribers-backend-mips Author: Xi Ruoyao (xry111) ChangesFix the issue: -mno-check-zero-division is not respected at -O0 for some test cases. Full diff: https://github.com/llvm/llvm-project/pull/204386.diff 2 Files Affected:
diff --git a/llvm/lib/Target/Mips/MipsFastISel.cpp b/llvm/lib/Target/Mips/MipsFastISel.cpp
index 9645fb5293609..ab76ee069fb15 100644
--- a/llvm/lib/Target/Mips/MipsFastISel.cpp
+++ b/llvm/lib/Target/Mips/MipsFastISel.cpp
@@ -74,6 +74,7 @@
using namespace llvm;
extern cl::opt<bool> EmitJalrReloc;
+extern cl::opt<bool> NoZeroDivCheck;
namespace {
@@ -1952,8 +1953,9 @@ bool MipsFastISel::selectDivRem(const Instruction *I, unsigned ISDOpcode) {
return false;
emitInst(DivOpc).addReg(Src0Reg).addReg(Src1Reg);
- if (!isa<ConstantInt>(I->getOperand(1)) ||
- dyn_cast<ConstantInt>(I->getOperand(1))->isZero()) {
+ if (!NoZeroDivCheck &&
+ (!isa<ConstantInt>(I->getOperand(1)) ||
+ dyn_cast<ConstantInt>(I->getOperand(1))->isZero())) {
emitInst(Mips::TEQ).addReg(Src1Reg).addReg(Mips::ZERO).addImm(7);
}
diff --git a/llvm/test/CodeGen/Mips/divrem.ll b/llvm/test/CodeGen/Mips/divrem.ll
index a29f2793c081f..e30764fef9042 100644
--- a/llvm/test/CodeGen/Mips/divrem.ll
+++ b/llvm/test/CodeGen/Mips/divrem.ll
@@ -12,6 +12,8 @@
; RUN: llc -mtriple=mips64 -mcpu=mips64r2 -mno-check-zero-division -relocation-model=pic < %s | FileCheck %s -check-prefixes=ALL,ACC64,NOCHECK
; RUN: llc -mtriple=mips64 -mcpu=mips64r6 -mno-check-zero-division -relocation-model=pic < %s | FileCheck %s -check-prefixes=ALL,GPR64,NOCHECK
+; RUN: llc -mtriple=mipsel -mcpu=mips32 -O0 -mno-check-zero-division -relocation-model=pic < %s | FileCheck %s -check-prefixes=NOCHECK
+
; FileCheck Prefixes:
; ALL - All targets
; ACC32 - Accumulator based multiply/divide on 32-bit targets
|
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
86a27b4 to
51a7b24
Compare
🐧 Linux x64 Test Results
✅ The build succeeded and all tests passed. |
🪟 Windows x64 Test Results
✅ The build succeeded and all tests passed. |
|
Looks like LLVM |
Fix the issue: -mno-check-zero-division is not respected at -O0 for some test cases.
51a7b24 to
6d41c9c
Compare
|
LGTM. |
|
Ping. |
|
Looks like you're really unlucky with the merge commits, there is some issue with The change has already been approved, unfortunately I think you just have to time the sync right for CI to pass. |
Fix the issue: -mno-check-zero-division is not respected at -O0 for some test cases. Co-authored-by: Folkert de Vries <folkert@folkertdev.nl>
Fix the issue: -mno-check-zero-division is not respected at -O0 for some test cases.