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: when SSE1 isn't available, f32 arguments are incorrectly passes as f64 #1861

Closed
llvmbot opened this issue Jun 3, 2007 · 10 comments
Closed
Labels
bugzilla Issues migrated from bugzilla llvm:codegen miscompilation

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Jun 3, 2007

Bugzilla Link 1489
Resolution FIXED
Resolved on Feb 22, 2010 12:41
Version 1.0
OS Linux
Reporter LLVM Bugzilla Contributor

Extended Description

llvm-gcc is miscompiling the following c code:


#define _ISOC9X_SOURCE 1
#include <math.h>
int main( void ) { return (lrintf(3.999f) > 0)?0:1; }


laurov@laurov-laptop:/tmp$ gcc test.c -o test -lm
laurov@laurov-laptop:/tmp$ ./test
laurov@laurov-laptop:/tmp$ echo $?
0
laurov@laurov-laptop:/tmp$ llvm-gcc test.c -o test -lm
laurov@laurov-laptop:/tmp$ ./test
laurov@laurov-laptop:/tmp$ echo $?
1

To reproduce this bug with llc must be used "llc -disable-fp-elim -fast -mcpu=i486".

@llvmbot
Copy link
Collaborator Author

llvmbot commented Jun 4, 2007

It is passing a 64-bit value for the 32-bit float, obviously wrong. It does not do this without -mcpu=i486.

@lattner
Copy link
Collaborator

lattner commented Jun 5, 2007

Very interesting. Investigating.

@lattner
Copy link
Collaborator

lattner commented Jun 5, 2007

Okay, the problem here is simple enough. f32 is not a legal datatype when you don't have SSE, so the call
argument is promoted from f32 to f64 (which is what the codegen thinks x87 FP registers are).

This obviously loses important information for the call, but it seems like we need to extend the ISD::CALL
node to represent this somehow. Dale, Evan, any thoughts?

@llvmbot
Copy link
Collaborator Author

llvmbot commented Jun 5, 2007

Perhaps change such parameters to bitcast to i32. That's sort of what's going on in a calling convention
where arguments are passed uniformly on stack or in int registers.

@lattner
Copy link
Collaborator

lattner commented Jun 5, 2007

Yep, that sounds like a good plan Dale. Can you please do this? It'll be in the ISD::CALL handling code of
Legalize, if you have any q's, please let me know.

-Chris

@llvmbot
Copy link
Collaborator Author

llvmbot commented Jun 5, 2007

That'll teach me to comment.
OK.

@lattner
Copy link
Collaborator

lattner commented Jun 5, 2007

:) It's a good chance to get exposure to the legalizer :)

@llvmbot
Copy link
Collaborator Author

llvmbot commented Jun 5, 2007

Yeah, I know. Forgot a smiley I guess.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Jun 7, 2007

@llvmbot
Copy link
Collaborator Author

llvmbot commented Jul 3, 2007

The fix above was removed in favor of:
http://llvm.org/viewvc/llvm-project?view=revision&revision=37847

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
kitano-metro pushed a commit to RIKEN-RCCS/llvm-project that referenced this issue Mar 14, 2023
kitano-metro pushed a commit to RIKEN-RCCS/llvm-project that referenced this issue Mar 14, 2023
refs llvm#1861 test仕様書に基づいたテストの変更

See merge request a64fx-swpl/llvm-project!94
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla llvm:codegen miscompilation
Projects
None yet
Development

No branches or pull requests

2 participants