[Mips] Do not emit teq if NoZeroDivCheck in FastISel#204386
Open
xry111 wants to merge 1 commit into
Open
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. |
Contributor
|
Looks like LLVM |
Fix the issue: -mno-check-zero-division is not respected at -O0 for some test cases.
51a7b24 to
6d41c9c
Compare
Contributor
|
LGTM. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix the issue: -mno-check-zero-division is not respected at -O0 for some test cases.