Skip to content
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

[X86-backend]LLVM regression: bitcast from i64 to x86_mmx type causes error in the current LLVM version but functions as expected in LLVM 19.1.0 and earlier #115806

Closed
DigOrDog opened this issue Nov 12, 2024 · 3 comments
Labels
backend:X86 question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

Comments

@DigOrDog
Copy link

Description

In the latest LLVM version, an attempt to bitcast from i64 to x86_mmx type in the IR code triggers an error that did not occur in LLVM 19.0 or any previous versions.

The following example demonstrates the problem:

@G = global i64 -9223372036854775808

define i64 @test49(i64 %arg, i64 %x, i64 %y) {
  %cond = icmp eq i64 %arg, %x
  %cond1 = icmp eq i64 %arg, %y
  %xmmx = bitcast i64 %x to x86_mmx
  %ymmx = bitcast i64 %y to x86_mmx
  %slct = select i1 %cond, x86_mmx %xmmx, x86_mmx %ymmx
  %psll = tail call x86_mmx @llvm.x86.mmx.psll.w(x86_mmx %slct, x86_mmx %slct)
  %retc = bitcast x86_mmx %psll to i64
  ret i64 %retc
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare x86_mmx @llvm.x86.mmx.psll.w(x86_mmx, x86_mmx) #0

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }

In LLVM 19.0 and earlier, this code successfully compiles, but in the current version, it throws a type error. This regression impacts code bases relying on x86_mmx operations and should be addressed for backward compatibility.

https://godbolt.org/z/q7oKz9nd1

@fzou1
Copy link
Contributor

fzou1 commented Nov 12, 2024

x86_mmx type had been removed by #98505, and documented on release notes (https://github.com/llvm/llvm-project/blob/main/llvm/docs/ReleaseNotes.md#changes-to-the-x86-backend):

Due to the removal of the x86_mmx IR type, functions with x86_mmx arguments or return values will use a different, incompatible, calling convention ABI. Such functions are not generally seen in the wild (Clang never generates them!), so this is not expected to result in real-world compatibility problems.

@DigOrDog
Copy link
Author

x86_mmx type had been removed by #98505, and documented on release notes (https://github.com/llvm/llvm-project/blob/main/llvm/docs/ReleaseNotes.md#changes-to-the-x86-backend):

Due to the removal of the x86_mmx IR type, functions with x86_mmx arguments or return values will use a different, incompatible, calling convention ABI. Such functions are not generally seen in the wild (Clang never generates them!), so this is not expected to result in real-world compatibility problems.

Thank you for your response! I appreciate the clarification. I’ll go ahead and close this issue now.

@EugeneZelenko EugeneZelenko added question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead! backend:X86 and removed new issue labels Nov 12, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 12, 2024

@llvm/issue-subscribers-backend-x86

Author: None (DigOrDog)

# Description In the latest LLVM version, an attempt to bitcast from i64 to x86_mmx type in the IR code triggers an error that did not occur in LLVM 19.0 or any previous versions.

The following example demonstrates the problem:

@<!-- -->G = global i64 -9223372036854775808

define i64 @<!-- -->test49(i64 %arg, i64 %x, i64 %y) {
  %cond = icmp eq i64 %arg, %x
  %cond1 = icmp eq i64 %arg, %y
  %xmmx = bitcast i64 %x to x86_mmx
  %ymmx = bitcast i64 %y to x86_mmx
  %slct = select i1 %cond, x86_mmx %xmmx, x86_mmx %ymmx
  %psll = tail call x86_mmx @<!-- -->llvm.x86.mmx.psll.w(x86_mmx %slct, x86_mmx %slct)
  %retc = bitcast x86_mmx %psll to i64
  ret i64 %retc
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare x86_mmx @<!-- -->llvm.x86.mmx.psll.w(x86_mmx, x86_mmx) #<!-- -->0

attributes #<!-- -->0 = { nocallback nofree nosync nounwind willreturn memory(none) }

In LLVM 19.0 and earlier, this code successfully compiles, but in the current version, it throws a type error. This regression impacts code bases relying on x86_mmx operations and should be addressed for backward compatibility.

https://godbolt.org/z/q7oKz9nd1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:X86 question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
Projects
None yet
Development

No branches or pull requests

4 participants