Skip to content

[MIPS] Fix failing to legalize load+call with vector of non-p2 intege… #109625

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 24, 2024

Conversation

yingopq
Copy link
Contributor

@yingopq yingopq commented Sep 23, 2024

…r type

Add a condition to check whether the vector element type is a power of 2.

Fix #102870.

@@ -124,7 +124,8 @@ unsigned MipsTargetLowering::getNumRegistersForCallingConv(LLVMContext &Context,
unsigned MipsTargetLowering::getVectorTypeBreakdownForCallingConv(
LLVMContext &Context, CallingConv::ID CC, EVT VT, EVT &IntermediateVT,
unsigned &NumIntermediates, MVT &RegisterVT) const {
if (VT.isPow2VectorType()) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stray empty line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied.

@@ -0,0 +1,30 @@
; RUN: llc -mtriple=mips-linux-gnu -mcpu=mips32 < %s | FileCheck %s --check-prefix=MIPS32

define void @call_v1i80() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add nounwind to suppress cfi.

; MIPS32-NEXT: jr $ra
; MIPS32-NEXT: addiu $sp, $sp, 8
Entry:
%0 = load <1 x i80>, ptr null, align 16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test case is over-reduced. Does the problem still reproduce if you replace the nulls here with a real pointer and a real function declaration?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this situation you mentioned also can be solved and the reported bug info was same as null pointer situation. I tested the following test case.

$ cat 1.ll
target datalayout = "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64"
target triple = "mipsel-unknown-linux-unknown"

define void @arg_v1i80(<1 x i80> %vec, ptr %p) {
  store <1 x i80> %vec, ptr %p
  ret void
}

define void @_start(ptr %p) nounwind{
Entry:
  %0 = load <1 x i80>, ptr %p, align 16
  call void @arg_v1i80(<1 x i80> %0)
  ret void
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add this to the illegal-vectors.ll test, which has a lot of related coverage.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need I added call_v1i80 to this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move test to illegal-vectors.ll done.

…r type

Add a condition to check whether the vector element type is a power of 2.

Fix llvm#102870.
@yingopq yingopq force-pushed the Fix_bug_issue_102870 branch from 85cb620 to 8c0a0f8 Compare September 24, 2024 03:25
Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nikic nikic merged commit debc325 into llvm:main Sep 24, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[MIPS] Failure to legalize load+call with vector of non-p2 integer type
2 participants