Skip to content

x86-32: missed zext folding optimization for cvtsi2ss #64174

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

Open
jroelofs opened this issue Jul 27, 2023 · 4 comments
Open

x86-32: missed zext folding optimization for cvtsi2ss #64174

jroelofs opened this issue Jul 27, 2023 · 4 comments

Comments

@jroelofs
Copy link
Contributor

This function:

float foo(unsigned char x) {
  return x;
}

compiles to (x86-32):

define float @foo(i8 zeroext  %x) nounwind  {
entry:
	%tmp12 = uitofp i8 %x to float		; <float> [#uses=1]
	ret float %tmp12
}

compiles to:

_foo:
	subl	$4, %esp
	movzbl	8(%esp), %eax
	cvtsi2ss	%eax, %xmm0
	movss	%xmm0, (%esp)
	flds	(%esp)
	addl	$4, %esp
	ret

We should be able to use:
cvtsi2ss 8($esp), %xmm0
since we know the stack slot is already zext'd.

rdar://5907648

@jroelofs
Copy link
Contributor Author

jroelofs commented Jul 27, 2023

Added a test referencing this in af6c1dbcdd15df92e9c902a28987301a18df8c91 3e0cdf3

@llvmbot
Copy link
Member

llvmbot commented Jul 28, 2023

@llvm/issue-subscribers-backend-x86

@RKSimon
Copy link
Collaborator

RKSimon commented Jul 28, 2023

Added a test referencing this in af6c1dbcdd15df92e9c902a28987301a18df8c91

@jroelofs I think this is actually 3e0cdf3 ?

eymay pushed a commit to eymay/llvm-project that referenced this issue Jul 28, 2023
@jroelofs
Copy link
Contributor Author

Added a test referencing this in af6c1dbcdd15df92e9c902a28987301a18df8c91

@jroelofs I think this is actually 3e0cdf3 ?

oops, yes. I think I might have copied the sha before rebasing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants