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

bitcast between long and double on x86-64 #1405

Closed
sunfishcode opened this issue Dec 4, 2006 · 6 comments
Closed

bitcast between long and double on x86-64 #1405

sunfishcode opened this issue Dec 4, 2006 · 6 comments
Assignees
Labels
backend:X86 bugzilla Issues migrated from bugzilla compile-fail Use [accepts-invalid] and [rejects-valid] instead

Comments

@sunfishcode
Copy link
Member

Bugzilla Link 1033
Resolution FIXED
Resolved on Feb 22, 2010 12:48
Version trunk
OS Linux
CC @lattner

Extended Description

On x86-64 a bitcast from long to double or double to long results triggers an
llc abort. Among other things, this comes up in the expansion of copysign.

long %p(double %t) {
%u = bitcast double %t to long
ret long %u
}

double %q(long %t) {
%u = bitcast long %t to double
ret double %u
}

With llc -march=x86-64, this gets

Cannot yet select: 0x8813318: f64 = bit_convert 0x88135c8

@sunfishcode
Copy link
Member Author

assigned to @lattner

@llvmbot
Copy link
Collaborator

llvmbot commented Dec 4, 2006

Mine.

@lattner
Copy link
Collaborator

lattner commented Dec 4, 2006

I think this is a codegen bug Reid,

-Chris

@llvmbot
Copy link
Collaborator

llvmbot commented Dec 4, 2006

This one looks like yours Evan. It seems the TD for x86-64 isn't handling bit
casts of 64-bit things.

The test case for it has already been committed to Regression/CodeGen/X86.

Reid.

@lattner
Copy link
Collaborator

lattner commented Dec 5, 2006

The preferred fix for this is to expand it into movd/movq. However, Evan is busy with other things, so
this won't happen in the near term. In the short-term, this patch gets us correct, but suboptimal (goes
through memory) code:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20061204/040803.html

Testcase here: CodeGen/X86/bitcast.ll

-Chris

_test1:
subq $8, %rsp
movsd %xmm0, (%rsp)
movq (%rsp), %rax
addq $8, %rsp
ret
_test2:
subq $8, %rsp
movq %rdi, (%rsp)
movsd (%rsp), %xmm0
addq $8, %rsp
ret

@lattner
Copy link
Collaborator

lattner commented Dec 5, 2006

Actually, MOVQ apparently doesn't do 64-bit GPR to SSE reg.

I implemented the movd case, compiling bitcast.ll::test3/test4 to:

_test3:
movd %xmm0, %eax
ret
_test4:
movd %edi, %xmm0
ret

Patch here:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20061204/040806.html

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:X86 bugzilla Issues migrated from bugzilla compile-fail Use [accepts-invalid] and [rejects-valid] instead
Projects
None yet
Development

No branches or pull requests

3 participants